Hello i have a mosaic dem and i have extracted contours wit interval = 2 meters. Now i want to convert contours to points xyz with distance of 1 meter from one point to another at the same contour line for each contour, any suggestion?
Solved! Go to Solution.
Good question. At first I thought that this should be available as standard tool in ArcGIS, but that seems not to be the case. Maybe it is because you can string the Densify and Feature Vertices to Points tools together and get the result, but this is not for all licenses available.
in which line i can change the code to do the procession for points every 3 meter for example.
and in which point i can define to run the procession for contour >1000 meters also.
That's my last question, you helped me a lot, thank you very much.
The code would look like the code below. Notice the following changes:
import arcpy, os fc_in = r"C:\Forum\Pasture\gdb\Contours.gdb\contours2" fc_out = r"C:\Forum\Pasture\gdb\Contours.gdb\contour_pnts03" fld_contour = "Contour" interval = 3 # pick points every x meter on every contour line # create empty output featureclass sr = arcpy.Describe(fc_in).spatialReference out_ws, out_name = os.path.split(fc_out) arcpy.CreateFeatureclass_management(out_ws, out_name, "POINT", fc_in, "DISABLED", "DISABLED", sr) # create a where clause where = "{0} > {1}".format(arcpy.AddFieldDelimiters(fc_in, fld_contour), 1000) # add field with contour value to output fc arcpy.AddField_management(fc_out, fld_contour, "DOUBLE") cnt = 0 with arcpy.da.InsertCursor(fc_out, ("SHAPE@", fld_contour)) as curs_out: with arcpy.da.SearchCursor(fc_in, ("SHAPE@", fld_contour), where_clause=where) as curs_in: for row_in in curs_in: polyline = row_in[0] contour = row_in[1] max_len = polyline.length d = 0 while d < max_len: pnt = polyline.positionAlongLine(d, False) curs_out.insertRow((pnt.firstPoint, contour, )) cnt += 1 if cnt % 100 == 0: print "Processing point: {0}".format(cnt) # pnt.firstPoint d += interval curs_out.insertRow((polyline.lastPoint, contour, )) cnt += 1
It works fine with shapefiles in folders...geodatabases aren't supported
Hi Xander,
Can it be done for the polygons?
https://community.esri.com/thread/262214-arcpy-script-to-write-same-record-in-another-feature-layer If it can be done for polygons, then it will answer my query.
Thanks in advance.
Kind regards,
Shahriar
The original questions extracts points from polylines (contours), but you want to extract points from a polygon? This is possible, but how should these points be distributed? Extract points from the outline of the polygon, generate random points inside the polygon, generate points at a certain distance inside the polygon?
If you have ArcMap 10.2.x at the Advanced level try the Densify tool or try this version for lower license levels, then convert to points