Using Functions in python - special emphasis on apparent reflectance

344
2
11-17-2013 05:17 AM
AnthonyNguy-Robertson
New Contributor
I am interested in using python to batch process a bunch of Landsat 8 images. I need reflectance as 0-1 or 0-100%, but there is no official Landsat 8 reflectance product. While there will probably be one eventually, I was hoping to use the apparent reflectance function in the meantime. I am new to 10.2 (used primarily 10.0) and I already have several python scripts doing what I need with the reflectance data, but I would like is to convert the Landsat 8 to reflectance using batch processing with a file saved rather than on-the-fly functionality that functions provide. 

FYI, I did figure out how to apply the functions and export the images with the reflectance conversion. I was hoping to avoid doing this individually to the 70 images i need to process.
0 Kudos
2 Replies
ShaunWalbridge
Esri Regular Contributor
Anthony,

There are a few ways to solve your problem. One is to create a model builder workflow which uses the raster calculator tool with the particular math you're using to convert between the images and reflectance. Save this model, and then from the catalog pane, you can right click on the model and select 'Batch', which will allow you to run the calculation on multiple rasters.

An alternative approach if you've done any Python programming is to use the arcpy raster functions to do the work directly. This way, you could, say have a file which listed each folder with your rasters, then iterate over the list, and perform the calculation directly in Python, which might look something like:

import arcpy
band_1 = arcpy.sa.Raster('c:/path/to/band1.tif')
band_3 = arcpy.sa.Raster('c:/path/to/band3.tif')
sum_reflectance = (band_1 + band_3)/(band_1.maximum + band_3.maximum)


cheers,
Shaun
0 Kudos
curtvprice
MVP Esteemed Contributor
One is to create a model builder workflow which uses the raster calculator tool with the particular math you're using to convert between the images and reflectance. Save this model, and then from the catalog pane, you can right click on the model and select 'Batch', which will allow you to run the calculation on multiple rasters.


I have not had good luck with the older 9.3-ish "batch" functionality with model tools; the model tries to run in "parallel". (I've found batch to work fine with script tools, I'm talking about "batching" model tools.)

I've had much better luck setting up the model to work on one input, and then either put an iterator tool in the model or call the model from a second model that has an iterator to loop through multiple inputs. A benefit of this approach is you can auto-name the outputs using model variables, instead of toiling to fill in the "batch" matrix with values.
0 Kudos