One of the most common tasks that programmers will be asked to tackle is to take an existing file and either reformat it, fix a problem in it, or convert the values in it to another format. This assignment will give you the chance to do this for yourself and put together a number of concepts you've learned so far.
First, you'll want to find a file that needs to be converted. You can use one from your own project if you have one and want to, otherwise, you can use the Avian Knowledge Network (AVN). Download the file locally and store it somewhere Python can access it. Then, start writing a program that will reformat the file to be they way you want. I recommend starting by reading the file and writing out the first few lines. Take a look at the lines and make sure you know the values are in the file that you want to access. Then, modify your code to convert the file line, by line, to the new format. Start with just a few lines and load them into ArcGIS to make sure they work correctly. Then, add a conversion to one of the values. Finally, add an "if" statement to only write out a portion of the file that you are interested in.
Write a function to convert coordinate values from degrees, minutes, and seconds (DMS) to decimal degrees (DD). You can use the code on this website for the contents of the function. Then, create a series of coordinates in DMS and use the function to convert them to decimal degrees.
Write another function to convert coordinate values from DD to DMS. Call the number with a series of coordinates and make sure they appear correctly.
A clever way to test the functions would be to call the function to convert the values from DMS to DD and then call the function to convert from DD to DMS with the new DD values. The string output from the DMS function match the original strings almost exactly.
© Copyright 2018 HSU - All rights reserved.