Workaround to not create new layer

المشرف العام

Administrator
طاقم الإدارة
I have a working code (shown at the bottom). The problem is process time is about 12 seconds for each loop. If I want to use this for the whole data I have (about 1 million points), it would take about half year. I think the problem is the following:

arcpy.GANeighborhoodSelection_ga(inFile, "neighbor2", pointcoord, "1", "1","5", "5", "0", "One sector")this tool always creates a layer for its output, so if I want use it, I have to delete the layer after I got the information I needed. I think the problem is that it constantly makes a new layer, which takes a lot of time.

I wonder If it's possible to force it to use the same layer somehow

import arcpyinFile = "C:\\Users\\Geri\\Desktop\\Sync\\arcpy\\inverz2b.shp"inFile2 = "C:\\Users\\Geri\\Desktop\\Sync\\arcpy\\inverz3b.shp"n=0arcpy.MakeFeatureLayer_management (inFile2, "3blayer")for num in range(0,4): arcpy.SelectLayerByAttribute_management ("3blayer", "NEW_SELECTION","FID = %s" % n) for row in arcpy.SearchCursor("3blayer"): x = row.X_Easting y = row.Y_Northing z = row.Z_Elevatio ratio = row.ratio pointcoord = str(x) + " " + str(y) arcpy.GANeighborhoodSelection_ga(inFile, "neighbor2", pointcoord, "1", "1","5", "5", "0", "One sector") for row in arcpy.SearchCursor("neighbor2"): x2 = row.X_Easting y2 = row.Y_Northing z2 = row.Z_Elevatio newx = x-((x-x2)/2) newy = y-((y-y2)/2) newz = z2-((z2-z)*ratio) print x, y, z, x2, y2, z2, newx, newy, newz n+=1 arcpy.Delete_management("neighbor2")

أكثر...
 
أعلى