Tuesday, July 21, 2015

Module 9 - Working with Rasters

This week we spent some time working with rasters. A straight-forward lab with exercises to walk us through listing rasters and raster properties, using the save method, reclassifying cell values, and using map algebra operators like Slope and Aspect. After the exercises we developed a script to create a raster output that identified a particular set of parameters.

This was an interesting script in that most all the code is inside an if-else conditional statement. After importing the modules and setting the workspace and overwrite abilities, I created an if statement that would check for the Spatial Analyst extension license availability, check it out, then run all my raster processing code, before checking the extension back in. An else statement was included to print a message if the license was not available, in which case the raster processing wouldn't occur.

Inside the if loop my raster functions started with the remap values function and reclassify function to change three forest landcover values to 1 (all other values would become zero). I then assigned a variable to an elevation raster, used the slope and aspect functions to create temporary rasters, performed slope and aspect calculations based on certain specified parameters, then combined all the rasters into one final raster which I saved to my Results folder.

It was a real pleasure seeing how easy Python could make raster processing. Not that the actual processing of the rasters were any faster than in ArcMap directly. Instead it was the time saved by not having to go into and out of each function's window and parameters in ArcMap or saving and sorting files. I do think in the future I might consider saving certain steps of the raster along the way if I thought I would need them, or needed to go back to a certain raster output along the way, as this script runs straight through from start to finish with no saves in between. All in all, a useful and common application for Python that I look forward to doing more with in the future.

Screenshot of raster created from script that reclassifies original raster to reflect forested land cover, slope between 5-20 degrees and aspect between 150-270 degrees (all values of 1).  



No comments:

Post a Comment