0

I am using ArcPy to clip from a huge raster (about 100.000km²) a smaller part (about 20.000m²) based on the extent of a input polygon. Running the analysis takes forever and although I let it run for hours, the clipping operation never seems to come to an end.

What settings can I use to improve the performance?

My code is as following. Note that I set the extent (extracted by the input polygon) and additionally the input polygon as in_template_dataset, to make sure that only this extent is kept. I save the output in the memory workspace as a TIFF file, because it is only an intermediate result. Is the TIFF format appropriate? I need to keep the cell size, exact raster values from the original raster.

extent = arcpy.Describe(inputPoly)
extent_in = str(extent.XMin) + " " + str(extent.YMin) + " " + str(extent.XMax) + " " + str(extent.YMax)
output = r"memory\clip.tif"   
arcpy.management.Clip(elevModel, extent_in, output, inputPoly, "", "NONE", "NO_MAINTAIN_EXTENT")
3
  • 1
    I take it your input raster is compressed, it takes a lot of CPU to decompress whole strips or blocks even if only one pixel is needed. Note that IN_MEMORY isn't stored in RAM it just means 'I don't care where ArcGIS stores this raster'. Be sure to set your arcpy.env.snapRaster and arcpy.env.cellSize to your input raster to avoid resampling. GeoTIFF may be appropriate but if you have enough space clip to an IMG file which is uncompressed, however most importantly set arcpy.env.pyramid = 'NONE' until you're producing output which will stop pyramiding the file that is irrelevant. Feb 18 at 7:22
  • My input raster is an Image Service, so I am not aware if it is compressed or not. Supposed it is compressed, is there a way to avoid decompressing and compressing again? Thanks for the hints for in_memory (I won't use that anymore) and the other environment settings. Why would one save it as IMG file and not GeoTIFF if it needs more space? It can't compute faster right? I need the format which saves the exact pixel values but is saved as fast as possible. Is it generally better to save the rasters in a Geodatabase or in a folder, or doesn't it matter?
    – GIS_USAr
    Feb 18 at 7:46
  • Your image service is definitely compressed, system admins stipulate that to save bytes. IMG format only supports RLE compression and is very rarely applied, on a single thread application like ArcGIS the bottleneck is CPU unless you're using very old laptop drives or network storage over a thin network, avoiding compressed format forces the bottleneck to the disc and ends up much faster. Building pyramids on a LZW compressed image takes nearly twice as long as generating the required raster. resources.arcgis.com/en/help/main/10.2/index.html#//… for more. Feb 19 at 7:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.