AnsweredAssumed Answered

Separating One Layer into different layers based on Longitude

Question asked by versm1ca on Oct 14, 2014
Latest reply on Oct 16, 2014 by versm1ca

Hello Experts,

 

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

 

Gratefully,

Ric

 

P.S.

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[0]:
               xcoord = ary[0][counter].X
               ycoord = ary[0][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)

Outcomes