GIS Programming - Mod 9
The assignment this week was to write a script that would create a raster output that would identify certain areas with a particular set of parameters. Those parameters were; slope, aspect, and land cover type. We accomplished this by piecing together many of the scripts we created in our exercise using multiple modules, functions and the one method available to the raster object, .save.
As usual we started by importing our modules and classes and setting our environments. We had the option of creating a geodatabase to save our final raster to or just saving it to a file. I chose to create a geodatabase because I wanted to refresh myself on the process since I think it's something I will use often.
There are different tools available in ArcMap depending on the licensing agreement you have. Many of the tools we use are Spatial Analyst tools which requires a higher level of licensing than the basic ArcMap package. The script we wrote was mostly contained within an If statement that would make sure the Spatial Analyst Extension was available before running the script, and an Else if it wasn't to print a message to the user letting them know the license wasn't available.
In between those if and else statements we checked out the license to use the Spatial Analyst tools, remapped and reclassified the land cover raster, recalculated the slope and aspect of the elevation raster and combined all five temporary rasters, then used the .save method to save them to a permanent file in the geodatabase. Once done with all of that the Spatial Analyst extension could be checked back in and the script ended.
In between those if and else statements we checked out the license to use the Spatial Analyst tools, remapped and reclassified the land cover raster, recalculated the slope and aspect of the elevation raster and combined all five temporary rasters, then used the .save method to save them to a permanent file in the geodatabase. Once done with all of that the Spatial Analyst extension could be checked back in and the script ended.
This assignment was pretty straightforward. Most of the steps were defined in the exercise so it was just a matter of going back through that to see what we had done. The one thing that caused me problems was I had copied a portion of the script exactly as it had appeared in the exercise, even though there were a few things about it I didn't understand. When my script was complete and I went to ArcMap to see what I had done, I found I had large patches of land that had no color. I went back through my script several times looking for the culprit and searched the discussion groups and consulted with classmates to try to determine the problem. Eventually it was discover that one of the parameters "NODATA" in the reclassifying step that had never been explained was what was causing the problem. Once I took that out everything came out as it was supposed to. And then hours later I found out how it original was was how it actually was supposed to be so I had to go back through everything and fix it all back to the way I originally had it.
To help keep track of where the script was in the process of running, a print statement was put in prior to each step. This not only helped to keep track of where the script was in the process, it was also a way to trace back where a problem was if the script failed. These results show the progress of the script, right to the successful end. It is a very useful step in the process of running the script, but very frustrating to deal with when creating the flow chart, since it adds so many extra elements to the chart. I often wonder if a generic note on the bottom of the page stating each step was preceded by a print statement would be good enough, but never think to ask.
No comments:
Post a Comment