April 19, 2014 GIT461 Final Exam Programming Project Due Date: End of Scheduled Final Exam Period Introduction For this project you will produce a Python 2.7 (PythonWin or IDLE) program that can generate a text file (.txt) that contains the decimal degree longitude (x) and latitude (y) coordinates of the lat.-long. reference marks commonly found on a U.S. Geological Survey topographic map. For example, standard USGS 1:24,000 7.5 minute quadrangles contain a 4 x 4 grid of 2.5 minute reference marks. Typically these reference marks are used to georeference raster images scanned into a computer. The USGS publishes a variety of topographic maps that have a variable number of reference marks and spacing between reference marks. The below table summarizes these variations: Topo Map 1:24,000 (7.5 x 7.5 min.) 1:62,500 (15 x 15 min.) 1:100,000 (1 deg. X 30 min.) 1:250,000 (2 deg. X 1 deg.) East-West extent 7.5 minute 15 minute 1 degree North-South extent 7.5 minutes 15 minutes 30 minutes Spacing 2.5 minutes (4 x 4) 5 minutes (4 x 4) 7.5 minutes (8 x 4) 2 degrees 1 degree 15 minutes (8 x 4) You program should be able to construct the above grids as a text file that can be imported easily into Excel. In fact, it should be versatile enough to construct any specified rectangular grid of reference points. The program should accept input on the command line, or prompt interactively for the line: Parameter 1: file name of output disk file Parameter 2: Longitude of southwest corner in (+/-)DDDMMSS format Parameter 3: Latitude of southwest grid corner in (+/-)DDMMSS format Parameter 4: Longitude of southwest corner in (+/-)DDDMMSS format Parameter 5: Latitude of southwest grid corner in (+/-)DDMMSS format Parameter 6: Latitude Spacing of grid in DDMMSS format Parameter 7: Latitude Spacing of grid in DDMMSS format The output file should consist of 3 columns separated by commas: Column 1: decimal degree longitude value (7 decimal places). Column 2: decimal degree latitude value (7 decimal places). Column 3: grid point count The index number of the grid point counter should increase by column first then by row, starting with the SW corner. For example, for the 16 grid points on a standard 7.5 minute 1:24,000 quadrangle the SW corner would be “1”, the SE corner would be “4”, the NW corner would be “13”, and the NE corner would be “16”. The output file should be comma delimited for easy importation into Excel. The longitude and latitude coordinates in the output file should be in decimal degrees for compatibility with the ESRI ArcMap “Import XY Data” menu option. Note that the “File > Data > Import XY data” can directly read a text file that is comma delimited so you do not have to import the output file into Excelyou can directly import it into ArcMap with the “Import XY Data” menu option. If a “+” sign is not included for any longitude or latitude coordinate your program should be able to adjust and assume that the number is positive. The spacing number will not need a “+/-“ indicator (i.e. there is no such thing as a “negative” grid spacing). The below quadrangles can be downloaded to test your program: 1. http://www.usouthal.edu/geography/allison/gy461/AlexCity_AL_24k.zip 2. http://www.usouthal.edu/geography/allison/gy461/Montgomery_AL_100k.zip 3. http://www.usouthal.edu/geography/allison/gy461/Montgomery_AL_250k.zip You should set the ArcMap project to UTM NAD27 zone 16 before adding the above georeferenced quadrangles to the project. Use the “Add XY data…” to add your text file generated by your program. The version of ArcGIS (10.1) that we are using can add a comma-delimited text file directly so you don’t have to load the text file into Excel if you want to skip that step. Remember that when you add this file that the coordinates in the file are decimal degree “geographic” coordinates. Useful Programming Functions The following are functions that will be useful for completing the lat-long grid programming project: len(string) : returns the length (no. of characters) in a string variable or expression float(string): returns the floating point equivalent of the string int(string): returns the integer equivalent of the string abs(number): returns the absolute value of the number (floating point or integer) str(number): returns the string equivalent of a number (floating point or integer) sys.argv[1]: returns the 1st parameter string on the command line Programming Outline 1. Initialize constants (output file name, length of longitude/latitude strings, end-of-line character, output file delimiter). 2. Retrieve and store command line parameters (or prompt interactively for string): a. Alex City AL 1:24k: “c:/temp/grid.txt -0860000 +325230 -0855230 +330000 000230 000230” b. Montgomery AL 1:100k: “c:/temp/grid.txt -0870000 +320000 -0860000 +323000 000730 000730” c. Montgomery AL 1:250k: “c:/temp/grid.txt -0880000 +320000 -0860000 +330000 001500 001500” d. Note that in the above examples the input string must be enclosed in quotes if you prompt interactively with an “input” statement. 3. Check latitude/Longitude strings for proper length and whether they have a “-“ sign (do this with a function because it is repetitive). 4. Convert longitude/latitude values to decimal degree values (use functions). 5. Open text file for output. 6. Calculate number of rows and columns for calibration marks. 7. Initialize counters for while loop. 8. Construct a double while-loop to loop through all columns and rows. 9. Calculate the decimal degree value of the longitude/latitude coordinate appropriate for the current row and column position. 10. Write the decimal degree longitude, latitude, and current calibration mark count to output file. 11. Close output file. Test your program using all 3 of the given USGS topographic maps.