Select to view content in your preferred language

Z-Coordinate Interpolation

2652
18
Jump to solution
11-18-2013 11:36 PM
StefanVollnhofer
Deactivated User
Hey there!
I've imported the surveypoints from an ascii file (add xy data -> export as shape -> import) and got the points now with x y and z coordinates in my map as shape-file.
How can i interpolate z-coordinates to new points now? I've selected the field "contains z coordinates" in the feature class?

Thanks!
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor
Hi Stefan,

I misunderstood what you were looking to accomplish before.  You are looking to populate the elevation values that are NULL by interpolating the elevation values from the surrounding points.  Is that correct?

You can do this by performing the following:

1.  Select all elevation values that are not NULL (i.e. NOT GelaendeH IS NULL)
2.  Run the IDW tool on the selection.  Before executing the tool, click on the Environments button > Processing Extent > set the Extent to the point feature class
3.  Run the Interpolate Shape tool on the point feature class using the output raster from the IDW tool.  A new feature class will be created
4.  With the new feature class, select all elevation values that are NULL (i.e. GelaendeH IS NULL)
5.  Open the attribute table > Right-click on the GelaendeH field > Calculate Geometry > Z coordinate of point

View solution in original post

0 Kudos
18 Replies
JakeSkinner
Esri Esteemed Contributor
You can run the following python script to update the Z value of each point:

import arcpy
from arcpy import env
env.overwriteOutput = 1

shp = r"C:\data\pointsZ.shp"

with arcpy.da.SearchCursor(shp, ["Z"]) as cursor:
   for row in cursor:
      vertexElevation = row[0]
      arcpy.MakeFeatureLayer_management(shp, "pts_lyr", "Elevation = " + str(vertexElevation))
      arcpy.Adjust3DZ_management("pts_lyr", "NO_REVERSE", vertexElevation)


You will just need to update the path for the 'shp' variable to your shapefile and change the field name ('Z') in the arcpy.da.SearchCursor to the elevation field name.  The code iterates through each point and updates the Z value based on the elevation field.
0 Kudos
StefanVollnhofer
Deactivated User
Seems like a very good solution to my problem but is this also possible if the shape is within a .mbd database?

tried it with "c:\data\mydb.mdb\z.shp" but it doesnt work. Do you have an idea how i can run this script for my data?
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Yes, you will just need to change the 'shp' variable to the path of your feature class in the MDB.  Ex:

shp = r"c:\data\mydb.mdb\<feature class name>"


You will not want to end the feature class name with a .shp since it is not a shapefile.
0 Kudos
StefanVollnhofer
Deactivated User
Hey, I've tried your python code for my file but there were the following error

>>> import arcpy
... from arcpy import env
... env.overwriteOutput = 1
... 
... shp = r"S:\Public\Projekte\2011\11420\WVA Hochneukirchen\wasser.mdb\LK\WaEinbauten"
... 
... with arcpy.da.SearchCursor(shp, ["GelaendeH"]) as cursor:
...    for row in cursor:
...       vertexElevation = row[0]
...       arcpy.MakeFeatureLayer_management(shp, "pts_lyr", "Elevation = " + str(vertexElevation))
...       arcpy.Adjust3DZ_management("pts_lyr", "NO_REVERSE", vertexElevation)
...       
Runtime error  Traceback (most recent call last):   File "<string>", line 11, in <module>   File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 2101, in Adjust3DZ     raise e ExecuteError: ERROR 000204: Fehler beim Erstellen des Eingabe-Feature-Cursors Fehler beim Ausführen von (Adjust3DZ).  
>>> 


Which means that the Input-Feature-Cursor could not be created, and the Adjust3DZ could not be run (I'm running the german version of ArcGIS)
I've updated the path to my feature-class (wasser.mdb\LK\WaEinbauten) as well the elevation field (GelaendeH).
0 Kudos
FabianBlau
Deactivated User
I guess, its no good idea to change a shp-file within a searchcursor using this shp-file.
Maybe you should copy the shp-file and use the copy in the cursor:
shp = r"S:\Public\Projekte\2011\11420\WVA Hochneukirchen\wasser.mdb\LK\WaEinbauten"
shp_copy = r"S:\Public\Projekte\2011\11420\WVA Hochneukirchen\wasser.mdb\LK\WaEinbauten_copy"

arcpy.Copy_management(shp , shp_copy) 

with arcpy.da.SearchCursor(shp_copy, ["GelaendeH"]) as cursor:
...
0 Kudos
StefanVollnhofer
Deactivated User
You're probably right that this is not a good idea, but the (same) error is still there 😞

used code now:

import arcpy
... from arcpy import env
... env.overwriteOutput = 1
...  
... shp = r"S:\Public\Projekte\2011\11420\WVA Hochneukirchen\wasser.mdb\LK\WaEinbauten"
... shp_copy = r"S:\Public\Projekte\2011\11420\WVA Hochneukirchen\wasser.mdb\LK\WaEinbauten_copy"
... 
... arcpy.Copy_management(shp, shp_copy) 
... 
... with arcpy.da.SearchCursor(shp_copy, ["GelaendeH"]) as cursor:
...  for row in cursor:
...   vertexElevation = row[0]
...   arcpy.MakeFeatureLayer_management(shp, "pts_lyr", "Elevation = " + str(vertexElevation))
...   arcpy.Adjust3DZ_management("pts_lyr", "NO_REVERSE", vertexElevation)
... 


Error:
Runtime error  Traceback (most recent call last):   File "<string>", line 14, in <module>   File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 2101, in Adjust3DZ     raise e ExecuteError: ERROR 000204: Fehler beim Erstellen des Eingabe-Feature-Cursors Fehler beim Ausführen von (Adjust3DZ).

Tried it also with "shp_copy" in line 12 instead of "shp"
Thanks for your help so far!
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Stefan,

Is your input feature class Z-enabled?  You can check by opening the attribute table.  The value for the Shape field should be 'PointZ'.
0 Kudos
StefanVollnhofer
Deactivated User
Yes, they are Point Z and in the Feature Class Options I have selected the option "Contains Z-Values"
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Can you upload a sample of your data?
0 Kudos