Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import arcpy
- inFC = r"C:temptestLines.shp"
- outFC = r"C:temptestLinesSplit.shp"
- if arcpy.Exists(outFC):
- arcpy.Delete_management(outFC)
- arcpy.CreateFeatureclass_management("C:/temp","testLinesSplit.shp","POLYLINE","#","DISABLED","DISABLED",inFC)
- arcpy.AddField_management(outFC,"inFID","LONG","#","#","#","#","NULLABLE","NON_REQUIRED","#")
- iCursor = arcpy.da.InsertCursor(outFC, ["inFID","SHAPE@"])
- with arcpy.da.SearchCursor(inFC,["OID@", "SHAPE@"]) as sCursor:
- for row in sCursor:
- inFID = row[0]
- # Print the current multipoint's ID
- #
- print("Feature {0}:".format(row[0]))
- partnum = 0
- # Step through each part of the feature
- #
- for part in row[1]:
- # Print the part number
- #
- print("Part {0}:".format(partnum))
- # Step through each vertex in the feature
- #
- prevX = None
- prevY = None
- for pnt in part:
- if pnt:
- # Print x,y coordinates of current point
- #
- print("{0}, {1}".format(pnt.X, pnt.Y))
- if prevX:
- array = arcpy.Array([arcpy.Point(prevX, prevY),
- arcpy.Point(pnt.X, pnt.Y)])
- polyline = arcpy.Polyline(array)
- iCursor.insertRow([inFID,polyline])
- prevX = pnt.X
- prevY = pnt.Y
- else:
- # If pnt is None, this represents an interior ring
- #
- print("Interior Ring:")
- partnum += 1
- del iCursor
- arcpy.JoinField_management(outFC,"inFID",inFC,"FID","#")
- import arcpy
- import numpy as np
- InFcVF = r"input.shp" # input feature class
- OutFcVF = r"output.shp" # output feature class
- print "Daten gelesen.."
- # Creates NumPy array from Input Feature
- array = arcpy.da.FeatureClassToNumPyArray(InFcVF,["SHAPE@XY"], "", sr, explode_to_points=True)
- print "Numpy Array created.."
- # if Feature as Array wasnt created
- if array.size == 0:
- arcpy.AddError(InFcVF + " contains no feature.")
- # Multipoint Feature from arra
- else:
- print "Aus Numpy Array wurde ein neues Multipoint Feature (VF) erstellt.."
- arcpy.da.NumPyArrayToFeatureClass(array, OutFcVF, ['SHAPE@XY'], sr)
- print "Numpy Array created.."`
Add Comment
Please, Sign In to add comment