Friday, July 24, 2015

GISProgramming: Module 9 - Working With Rasters

     Last week we examined vector data and geometries. This week's assignment looks at the alternate data type used in GIS, raster data. This module covers examining and manipulating raster data programmatically. To do so, the Spatial Analysis extension must be licensed and enabled. Writing in code that checks for the extension/module is helpful for ensuring that any person who makes use of the program on their computer doesn't get an error but instead receives a message the the extension is not available to them. The program I wrote this week does just that. If the extension is licensed then the program runs to completion. If the extension is not available then an alternate message prints that the user does not have access to the extension.
      For this programming exercise, we do have access the the Spatial Analysis module. The module is imported with all of its tools. Two particular rasters are used, a landcover and elevation raster. The Remap class and Reclassify tool are used to reclassify landcover values. Then, a particular range of slope values and aspect values are used to select specific parameters of the elevation raster. All of these raster outputs and selections are temporary. They are combined using map algebra and the final raster output is saved as a permanent file. Below is an image of the final raster result. There is also a screenshot of the interactive window showing the progression of the program by way of print statements.
    
The final raster result showing reclassified landcover data
that has a specific range in slope and aspect.

Screenshot of the interactive window showing print statements that track the progress of the program. 
     I found this program much easier to write than last week's foray into geometries. The geometries program required nested for loops and this program only required a single if/else statement (which I find conceptually simpler perhaps due to previous exposure in a different programming language).  

No comments:

Post a Comment