I have a river shapefile and need to ensure every vertice has a lower elevation that the previous uphill vertice.
I have converted the polylineZ to points using ET GeoWizards.
This gives me a Z value for every vertice.
I have added a field called ElevDiff.
I need to calculate the difference in elevation values from the previous vertice to the next in the attribute table.
If the value is negative, I know the line does not flow downhill at this point.
This is an easy task in Excel but I am wondering if there is a python script or easy way to calculate this using ArcGIS.
I do not have any extensions (i.e. Spatial Analyst, 3D Analyst, Newtwork Analyst).
Answer
I would be extremely cautious assuming the order of the vertices (FID) in the table goes in the order of your river flow. If you had an order_ID this could be set up to use that instead. I'm not familiar with ET Geo Wizard, if your points have the elevations in a field rather than as z values replace "SHAPE@Z" with that field name.
import arcpy
from arcpy import da
vertices = "File_Name.shp"
elev1=0
with arcpy.da.UpdateCursor(vertices, ["FID", "SHAPE@Z", "ElevDiff"]) as cursor:
for row in cursor:
elev2 = float(row[1])
row[2] = (elev1 - elev2)
elev1 = elev2
cursor.updateRow(row)
No comments:
Post a Comment