I'm trying to automate my work using ArcPy in PyCharm on Windows. However, when I run the following (abridged) loop, it exits at random points: sometimes at the 4th iteration, sometimes at the 31st, sometimes it manages to get to 100 but never close to the 90.000 iterations it's supposed to!
The error is:
Process finished with exit code -1073741819 (0xC0000005)
import arcpy
arcpy.CheckOutExtension("Spatial")
arcpy.env.overwriteOutput = True
input_path = "D:/.../05_reprojected"
current_path = "C:/.../Arcpy-test"
for filename in os.listdir(input_path):
glacierID = glacierLocation[27:35]+"_"+glacierLocation[36:41]
bedrockRaster = Raster(glacierLocation)
filledBedrockRaster = Fill(bedrockRaster)
fill_save = current_path+"/filled_"+glacierID+".tif"
filledBedrockRaster.save(fill_save)
sinks = Con(fill_save > bedrockRaster, 1)
regionGrp = RegionGroup(sinks)
# sometimes it breaks here, and sometimes it doesn't
region_save = current_path+"/regionGrp_"+glacierID+".tif"
regionGrp.save(region_save)
...
# and the loop continues
I know from googling that this has something to do with Windows access violation errors. The regionGroup(sinks)
output in the terminal is:
Starting region group
Connecting regions
Compacting labels
# and here it breaks sometimes with the above mentioned error
Where would this access violation take place?
I store every output in a separate folder for every iteration. If RegionGroup
creates an own tmp-folder, I don't know how to find it and check for issues.
I have looked at many questions on GIS. There is an ArcGIS (Desktop, Engine) Background Geoprocessing 64-bit Arcpy Exit and Shutdown Patch mentioned at ArcPy 64bit giving 0xC0000005 error with PyCharm, but it is not for ArcGIS Desktop 10.7, which seems to indicate that it should be fixed in this version (but is not, apparently). Other questions are related to PyQGIS or other workflows that do not apply to mine.
EDIT: I've tried to run the script via the ArcGIS python directly in the console and but the error was the same. So it does not seem to be connected to PyCharm.
No comments:
Post a Comment