0

Question: Is it possible to automate the functionality of right-click layer in TOC > data > export raster using arcpy in ArcGIS Pro? Specifically including the clipping extent options? I have reviewed several similar SE posts (most relevant here), but all of them suggest using "copy raster", which does not have the aforementioned clipping options.

Background: I'm trying to download data from an image service (located here). I only want to download subset of the data, similar to a clip or extract by mask (see image below)

aoi

If I right-click and do data > export raster with the full AOI, i get the following error.

enter image description here error

If I tile up the AOI into much smaller pieces it works perfectly. However, I then face the issues of having to manually right click and extract hundreds of times. I would instead like to automate this with arcpy, but 'export raster'. doesn't seem to be an actual geoprocessing tool.

edit: I've also tried using extract by mask, which works but is far slower. ~5 minutes per 'tile', as opposed to just a few second with when using 'Export Raster'

2
  • Use Copy Raster, set extent in the tool environment settings (or arcpy.env.Extent if scripting)
    – user2856
    May 18, 2020 at 21:29
  • Yeah I tried that, for some reason it keeps on the dreaded 999999 error. Extract by mask is working albeit slowly ...
    – Nick
    May 18, 2020 at 21:45

2 Answers 2

1

The answer to your question is yes, the Clip Raster tool does exactly that. https://pro.arcgis.com/en/pro-app/tool-reference/data-management/clip.htm

Your issue is that you are working with a very large raster from an image service, and running into memory limitations. I think its just going to take a long time. You could try writing the output to memory if its just going to feed into another process.

https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/basics/the-in-memory-workspace.htm

1
  • Can't seem to get that working either - using clip with the image service raster just crashes everything. Thank you, though!
    – Nick
    May 19, 2020 at 16:40
0

Two suggestions:

  • Use ExtractByMask instead of Clip Raster
  • Before running the extraction, reset your environment extents to limit the scope of what the model is processing.

I have been working with a large raster dataset and the ExtractByMask took several minutes per sub-area before I made this change. Don't forget to reset the environment extents when you are done.

# This is the FC that defines the boundary you want to use to extract
extraction_fc 

# Set environment extent temporarily
extraction_extent = arcpy.Describe(extraction_fc).extent
arcpy.env.extent = extraction_extent

# clip raster to extent
out_raster = os.path.join('path','to','output')
outExtractByMask = ExtractByMask(in_raster, extraction_fc)
outExtractByMask.save(out_raster)

# reset environment extent
arcpy.env.extent = "MAXOF"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.