import arcpy from arcpy import env env.workspace = r"C:\TEMP\Python\test.gdb" env.overwriteOutput = 1 fc1 = "River" fc2 = "New_Poyline" coordList = [] arcpy.FeatureVerticesToPoints_management(fc1, "vertices", "MID") arcpy.AddXY_management("vertices") rows = arcpy.SearchCursor("vertices") for row in rows: X = row.getValue("POINT_X") Y = row.getValue("POINT_Y") coordList.append([X, Y]) del row, rows coordList.sort() point = arcpy.Point() array = arcpy.Array() for feature in coordList: point.X = feature[0] point.Y = feature[1] array.add(point) polyline = arcpy.Polyline(array) array.removeAll() arcpy.Delete_management("vertices") arcpy.CopyFeatures_management(polyline, fc2)
import arcpy from arcpy import env env.workspace = r"D:\pomme de terre 2\pomme de terre2.gdb" env.overwriteOutput = 1 fc1 = "Flowline24k_sl_u2" fc2 = "Graph" for a in range(1,6): obj = "ID_1=%d" % (a) arcpy.SelectLayerByAttribute_management (fc1,"NEW_SELECTION",obj) arcpy.SelectLayerByLocation_management(fc1,"INTERSECT",fc1) arcpy.CopyFeatures_management(fc1,"hidden") arcpy.SelectLayerByAttribute_management (fc1,"CLEAR_SELECTION") coordList = [] arcpy.FeatureVerticesToPoints_management("hidden", "vertices", "MID") arcpy.AddXY_management("vertices") rows = arcpy.SearchCursor("vertices") for row in rows: X = row.getValue("POINT_X") Y = row.getValue("POINT_Y") coordList.append([X, Y]) del row, rows coordList.sort() point = arcpy.Point() array = arcpy.Array() for feature in coordList: point.X = feature[0] point.Y = feature[1] array.add(point) polyline = arcpy.Polyline(array) array.removeAll() arcpy.Delete_management("vertices") arcpy.Delete_management("hidden") arcpy.CopyFeatures_management(polyline, fc2)
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.