3

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?

3

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 use EditRasterFunction_Management (docs) to apply the template to new rasters. The XML files aren't too complicated, and can be parsed with lxml 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.

  • Many thanks for your response, however I need to permanently stretch an image (which is an image rather than raster DTM) and save it as a new standard deviation stretch image- basically enhance an image. – meryloo Mar 29 '14 at 17:48
  • @meryloo: I've rewritten my answer to match your true question -- I hadn't initially realized what you were intending to do. – scw Mar 30 '14 at 4:22
  • Many thanks for your reply and help! - this is what I was looking for :) – meryloo Apr 1 '14 at 7:56
1

I also came across the useful PyStretch python library [jlaura] that provides functions for different image stretch, such as standard deviation, percent clip, histogram equalize + common image filtering functions.

Please find the resources under the following links:

download

user manual

usage examples

Hope it may be useful for you as well!

Meryloo

Your Answer

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

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