添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange

Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.

Sign up to join this community

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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 RegionGroupcreates an own tmp-folder, I don't know how to find it and check for issues.

I have looked at many questions on GIS Stack Exchange. 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.

You could try converting to numpy Array (rastertonumpyarray) then try something like this then convert back to raster – BERA Jan 23, 2020 at 7:41 This is the same error as seen at gis.stackexchange.com/q/126250/115 (which showed up in the Related questions in the right hand panel. – PolyGeo Jan 23, 2020 at 7:46 It seems to be quite a common error from both ArcPy and PyQGIS, and often associated with PyCharm - see gis.stackexchange.com/search?q=0xC0000005 – PolyGeo Jan 23, 2020 at 7:49 Instead of creating file & folder paths by string concatenation, use os.path.join. For example region_save = os.path.join(current_path, "regionGrp_{}.tif".format(glacierID). – Bjorn Jan 23, 2020 at 17:17

Thanks for contributing an answer to Geographic Information Systems Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.