while working with Python scripts or with ModelBuilder, at some point I usually end up that I have to write some data to my HDD instead of keeping it in memory. The result might be that I create a couple thousand featureclasses where every single one might hold tens of thousands features.
Since those featureclasses still represent only temporary products they need to be deleted in a later step. When I try this in a script I would use 'ListFeatureClasses' with some wildcard and a for-loop to delete the items. That will finally not work, for whatever reason and the script will crash. If I try the same thing in ArcCatalog by selecting the featureclasses and go for the delete button then ArcCatalog will simply get unresponsive and finally the system tells me that the application stopped working.
The only way I found so far is to use the Python window from within ArcCatalog or ArcMap, list all the classes of interest, do the for-loop and delete the files listed. --> That's terrible slow!!!
I have three questions:
How can it be that the same code works in the Python window, but not in an external script?
Is there a way to speed up the process of deleting the files?
Since ArcSDE is invoked in ArcGIS Desktop, is there a way to use SQL to access the FGDB and delete the data that way?
Bests Thomas
- We are living in the 21st century. GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
If you're really creating tens of thousands of scratch feature classes, then the best way to handle deletion is to make the entire FGDB scratch for that one session, so that the entire .gdb directory can be deleted (without iterating the members).
File geodatabase and ArcSDE are very different creatures -- there is no SQL engine to end-around the file geodatabase management code.
it would be nice if I could keep everything in scratch but either I didn't figure it yet out, or it is not possible. One example: I have 2500 points, a road network and 2400 polygons... I want to know what is the shortest route from each of the 2500 points to every polygon. So, I create all the intersection points (70.000) for the road network with the polygons and use the network analyst to do the routing for every point, using an OD Cost Matrix. That includes an iteration over the 2500 points. Since there are always a couple of intersection-points per polygon I have to figure out what the shortest route is. For that I am using the 'Statistics_analysis' function...
So far I did not find a possibility to get to that point without writing the result at one point out of memory.
Would be really glad if there is a way.
Cheers Thomas
- We are living in the 21st century. GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
No, I mean a scratch file geodatabase, as in throw-away, not in-memory. Create a new file geodatabase for each analysis, copy the tables you need, do the analysis, then delete the entire workspace, not each intermediary table.