Goals
The goal of this exercise is to use a suite of loops to clip and project a directory of scanned USGS topographic sheets into a seamless raster. The topographic sheets are in a layout referred to as a tile index or a quad index. These quads have a collar around the edge of the map that needs to be clipped away so that we have a seamless mosaic.
Methods
This script was easily the longest and most complex script that was written during this class. That being said, it starts off the same as just about all of the other scripts. First, a print statement showing that the script was working is written. Second, all of the system modules need to be imported. For this script, os, shutil, time, datetime, and arcpy were all imported. The next step, similar to previous scripts, is to write a block of code that allows existing files to be overwritten. The next step was to create variables. Some of the variables created included our workspace, geodatabase path, featuredataset path, and clip geodatabase path. The next thing in the script is two blank lists that will end up being populated with the name of the topos as we iterate through loops later. Along with the blank lists, file location and files name for some of the created data sets are set up. The next step was to create a spatial reference object. Next a boolean loop is set up. If the condition is true the function will then traverse a workspace and final all files with a specified type. Inside of the loop, we want to be able to track the progress, to do this, you can set a letter as a variable equal to zero. You then add one to the variable later on as the loop progresses to indicate how many rasters are left. The next step in the script is applying the walk to the directory. Next we set up an interaction loop. The first thing that needs to be done in the iteration loop is set up the counter. Next the names of the top will be formatted. Once the names are reformatted, the process of projecting the topos can be executed. Next we take the projected topo and create a polygon of the topos footprint which includes the collar. Now the tiles can be added to the list of tiles and then the tiles can be merged together. Next we set up an if loop that will clip the collar from the tiles one by one. There is an if else statement inside the loops that will allow a tile to pass over the clipping tool if it has already been clipped. In this case the first tile that went through the loop had already been clipped. Once All of the tiles have been clipped then the mosaic tool is used to combine all of the clipped tiles into one larger topo map.
Results
The results of this exercise were the projected and clipped rasters and then a mosaic of all of the rasters combined together. Below are images that first show the script that was written in the exercise and below that is the final mosaic topo map that was created.
Conclusion
This exercise was difficult, but, it definitely helped get more practice with loops and cursors along with many other elements of python scripts. The final map came out looking good besides the discoloring. The discoloring in the map is just a result of the way the USGS maps are scanned. All of the data in this exercise was provided by USGS topo maps! Overall this was a difficult but worthwhile exercise for this class.

No comments:
Post a Comment