Struggling with in_memory to erase faster

المشرف العام

Administrator
طاقم الإدارة
I want to delete all points inside a polygon layer:

import arcpyimport timearcpy.env.workspace = r"E:\DensityMaps\DensityMapsTest1.gdb"arcpy.env.overwriteOutput = Truestart_time = time.time()arcpy.Erase_analysis("Test_Points_Project", "Europe_coastline_NoLakesRivers", "PointsPolyErase1")print "Erase ended "+("--- %s seconds ---" % (time.time() - start_time))This lasts 36,9 seconds

Then I read this post saying that the process can be dramatically optimized using in_memory. I give it a try:

import arcpyimport timearcpy.env.overwriteOutput = Truestart_time = time.time()#Copy points to in_memoryinFeature = r"E:\DensityMaps\DensityMapsTest1.gdb\Test_Points_Project"memoryFeature = "in_memory\PointsMemory"arcpy.CopyFeatures_management(inFeature, memoryFeature)#Erase points that are inside polygonsarcpy.Erase_analysis(memoryFeature, r"E:\DensityMaps\DensityMapsTest1.gdb\Europe_coastline_NoLakesRivers", "PointsMemory")#Copy points back to directoryarcpy.CopyFeatures_management("PointsMemory", r"E:\DensityMaps\DensityMapsTest1.gdb\PointsPolyErase")print "Erase ended "+("--- %s seconds ---" % (time.time() - start_time))This lasts 38.4 seconds, 1,5 seconds slower than the previous script. I am obviously doing something wrong. Very wrong.

It's very important to make the process faster because the original point file contains 22 millions points (1,5 GB). If I don't manage to do it fast the operation can last about 24 hours.

Here are the files if you want to test



أكثر...
 
أعلى