Project 2: Batch reprojection tool for vector datasets | GEOG 485: GIS Programming and Automation

Some GIS departments have determined a single, standard projection in which to maintain their source data. The raw datasets, however, can be obtained from third parties in other projections. These datasets then need to be reprojected into the department's standard projection. Batch reprojection, or the reprojection of many datasets at once, is a task well suited to scripting. In this project you'll practice Python fundamentals by writing a script that re-projects the vector datasets in a folder. From this script, you will then create a script tool that can easily be shared with others. The tool you will write should look like the image below. It has two input parameters and no output parameters. The two input parameters are: Successful completion of the above requirements is sufficient to earn 90% of the credit on this project. The remaining 10% is reserved for 'over and above' efforts which could include, but are not limited to, the following: You are not required to handle datum transformations in this script. It is assumed that each dataset in the folder uses the same datum, although the datasets may be in different projections. Handling transformations would cause you to have to add an additional parameter in the Project tool and would make your script more complicated than you would probably like for this assignment. The Lesson 2 data folder contains a set of vector shapefiles for you to work with when completing this project (delete any subfolders in your Lesson 2 data folder—you may have one called PracticeData—before beginning this project). These shapefiles were obtained from the Washington State Department of Transportation GeoData Distribution Catalog (link is external), and they represent various geographic features around Washington state. For the purpose of this project, I have put these datasets in various projections. These projections share the same datum (NAD 83) so that you do not have to deal with datum transformations. There are a lot of ways to insert '_projected' in the name of a dataset, but you might find it useful to start by temporarily removing '.shp' and adding it back on later. To make your code work for both a shapefile (which has the extension .shp) and a feature class in a geodatabase (which does not have the extension .shp), you can use the following: In the above code, fc is your feature class name. If it is the name of a shapefile it will include the .shp . The replace function searches for any string '.shp' (the first parameter) in the file name and replaces it with nothing (symbolized in the second parameter by empty quotes ''). So after running this code, variable rootName will contain the name of the feature class name without the '.shp' . Since replace(...) does not change anything if the string given as the first parameter does not occur in fc, the code above can be replaced by just a single line: but hard-coding numbers other than 0 or 1 in your script can make the code less readable for someone else. Seeing a function like replace is a lot easier for someone to interpret than seeing -4 and trying to figure out why that number was chosen. You should therefore use replace(...) in your solution instead. This courseware module is part of Penn State's College of Earth and Mineral Sciences' OER Initiative (link is external). Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License (link is external). The College of Earth and Mineral Sciences is committed to making its websites accessible to all users, and welcomes comments or suggestions on access improvements. Please send comments or suggestions on accessibility to the site editor (link sends e-mail). The site editor may also be contacted with questions or comments about this Open Educational Resource. The John A. Dutton e-Education Institute is the learning design unit of the College of Earth and Mineral Sciences (link is external) at The Pennsylvania State University (link is external). 2217 Earth and Engineering Sciences Building, University Park, Pennsylvania 16802 (link is external) 877-778-4471 | Contact Us Privacy & Legal Statements (link is external) | Copyright Information (link is external) The Pennsylvania State University © 2014 Source.

Яндекс.Метрика Рейтинг Free Web Counter
page counter
Last Modified: April 27, 2015 @ 12:00 am