I am looking for ways of applying a permanent standard deviation stretch to rasters via a Python script.
Are there any ArcPy raster stretch functions? I was looking for a reference but could not find any.
Are there any other Python libraries that can perform the stretch?
Best Answer
To make large changes to your raster, look at Raster Functions. What I'd recommend is initially creating the stretch you'd like to apply using the raster function tools, and then saving that to a template (
.rft.xml
). From there, you should be able to useEditRasterFunction_Management
(docs) to apply the template to new rasters. The XML files aren't too complicated, and can be parsed withlxml
or equivalent, if you need to programmatically manipulate the function template.Once you're done applying the functions you need, you can just use
CopyRaster_management
to pull out the modified result into its own layer -- function chains are primarily intended for on the fly raster operations, and this step is needed to make the changes directly to the pixel values.