Friday, 17 March 2017

arcobjects - Distance analysis of 3-D surface in ArcGIS using VB.NET


Using VB.NET I created a 3D polygon in ArcGIS to model a fault plane and now I want to find two different distances from a point on earth's surface. How to go about this? Can some one help with the code?


I have used following code to create polygon with 4 points. For example Lat1, long1, z1 are latitude, longitude and depth of the first vertex. Now I need to find the following distances:





  1. Nearest distance from a point (Defined by its own lat and long) on earth's surface to the 3-D surface




  2. Nearest distance from the same point to the polygon formed by projecting this 3-D polygon on earth's surface




Dim pPoint As IPoint = New PointClass()
Dim pPointCollection As IPointCollection = New RingClass()
Dim pGeomCollection As IGeometryCollection = New PolygonClass()

pPoint.PutCoords(lat1, long1)
pPoint.Z = Z1
pPointCollection.AddPoint(pPoint)
pPoint.PutCoords(lat2, long2)
pPoint.Z = Z2
pPointCollection.AddPoint(pPoint)
pPoint.PutCoords(lat3, long3)
pPoint.Z = Z3
pPointCollection.AddPoint(pPoint)
pPoint.PutCoords(lat4, long4)

pPoint.Z = Z4
pPointCollection.AddPoint(pPoint)
pGeomCollection.AddGeometry(pPointCollection)
Dim pOutGeometry As IGeometry = CType(pGeomCollection, IGeometry)
Dim pZaware As IZAware = CType(pOutGeometry, IZAware)
pZaware.ZAware = True

For the first distance, we can use "Near Tool" in ArcGIS but I am not knowing how to initiate that and find the distance.For the other distance we can form a 2D polygon by ignoring the Z values of vertices and use the same Near Tool. Please help me with the code for this idea.



Answer



As Hornbydd said you want to use the IProximityOperator3d interface.



In order to find a distance from the Earths' surface you need to get a good model of the Earth, after that it's just a return distance. There are different operators depending on how this is modeled: DEM, TIN, Terrain... when you've got that model post that as a separate question as the methods are different, as PolyGeo said.


The proximity operators can be implemented by any geometry type (high level that is, Polygon not Ring, Polyline not path) to any high level geometry type.


From where you were in your code, and assuming you have another 3d geometry pOtherGeometry you need to get the minimum distance to:


Dim pOutGeometry As IGeometry = CType(pGeomCollection, IGeometry)
Dim pZaware As IZAware = CType(pOutGeometry, IZAware)
pZaware.ZAware = True
' add this'
Dim pProxOp as IProximityOperator3d = CType(pOutGeometry,IProximityOperator3d)
Dim pReturnDistance as double = pProxOp.ReturnDistance3D(pOtherGeometry)

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...