I am given a shape file which consists of polylines in just one
layer and my task is to separate them into three layers based on
the longitude of the vertices of the said polylines. So that
polylines whose vertices are between say 100 to 110 should be in
LayerA, and those between 111 to 120 should be in LayerB .. is this
possible to do in python?
Any help greatly appreciated
I am a bit new at this .. so far as starters, I have succeeded in extracting the latitudes and longitudes
using the technique below but I am not sure if my approach is the the right way or if there is a more
correct/proper way to do it.
import arcpy strKPipeLayer = 'TestPipeLines' strKPipeFullPathShape = r"F:\TestPipeLines.shp" strK = r"F:\creatingMeridians.mxd" mxd = arcpy.mapping.MapDocument(strK) for ly in arcpy.mapping.ListLayers(mxd): if (ly.name == strKPipeLayer): rowData = arcpy.SearchCursor(strKPipeFullPathShape) for rowDatum in rowData: arcpy.Describe poly = rowDatum.Shape lst = list(poly) ary = arcpy.Array(lst) for ply in ary: countPoly = countPoly + 1 print "Polyline # " + str(countPoly) print ' ' counter = 0 for pt in ary: xcoord = ary[counter].X ycoord = ary[counter].Y point = arcpy.Point(xcoord,ycoord) ptGeometry = arcpy.PointGeometry(point) print str(xcoord) + ',' + str(ycoord) + ',' + '0.0000' counter = counter + 1
Message was edited by: Curtis Price (added code highlight in-place)