Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to GIS Programming Final Project Submitted by Todd Lenkin Geography 375 Spring of 2011 American River College.

Similar presentations


Presentation on theme: "Introduction to GIS Programming Final Project Submitted by Todd Lenkin Geography 375 Spring of 2011 American River College."— Presentation transcript:

1 Introduction to GIS Programming Final Project Submitted by Todd Lenkin Email: tlenkin@yahoo.com Geography 375 Spring of 2011 American River College

2 Introduction & Set up Script This Python script has been created to compare the location of two sets of points that are supposed to represent the same thing. Specifically, underground fuel storage tanks within the County of El Dorado. The two sources of data are the county database and the state waterboard's website known as Geotracker.Geotracker The script begins with a brief description. The modules are imported: arcpy, sys & traceback. The workspace environment is identified as a file geodatabase that has already been created. It contains the two tables with the data that were imported from Excel spreadsheets. The variables are set for the tables, layers and files.

3 Script Description Import Modules Set Current Workspace Set Variables Introduction & Set up Script

4 Make Data Into Features The first process is to create layers with the data using the latitude and longitude fields from each table. The script checks if the layer(s) exists and if so, performs a delete of the file. Then the spatial reference is set to the geographic coordinate system being used (NAD 83). Then the Make XY Event Layer tool is used. Get Count is used to print the results. The second process is to make features from the layers. The script checks if the feature class(es) exist and if so, performs a delete of the file. Copy Features tool is used to make feature classes. A string is used to print that the features have been copied.

5 If Exists, Delete Set Spatial Reference for Geographic Coordinate System Make XY Event Layer Print Result using Get Count If Exists, Delete Copy Features Print Finished String Make Data into Features

6 Project, Near Analysis & Join Fields The third process is to convert the features into a projected coordinate system so that the units are in feet. The script checks if the feature(s) exists and if so, performs a delete of the file. Then the spatial reference is set to the projected coordinate system being used (State Plane). Then the Project tool is used. A string is used to print that the projected feature classes have been created. The forth process performs the Near analysis with the county features being the target. The distance parameter is 1,000 feet. The fifth process is to determine if the closest point represents the same facility. The Join Field tool is used to add the Global ID field from the state features to the county features.

7 If Exists, Delete Set Spatial Reference for Projected Coordinate System Print Finished String Near Analysis Print Finished String Join Field (Global ID) Project, Near Analysis & Join Field

8 Select Analysis The sixth process is create three feature classes that represent the different scenarios of matching the county point to the state point. If the Global ID fields are equal, then the closest state point to the county point is a match. If the Global ID fields have a null value, then either the state or county record does not exist. And if the Global ID fields do not match, then the closest point is not a match and further analysis is required. The script checks if the feature(s) exists and if so, performs a delete of the file. The Select tool is used to create the feature class. Get Count is used to print the results.

9 If Exists, Delete Select where Global ID Matches Select where Global ID has NULL Value Select where Global ID is not a Match Print Result using Get Count Select Analysis

10 Buffer, Spatial Join & Select The seventh process is to create buffer polygons around the three county points where the closest state point is not a match. The script checks if the feature class exists and if so, performs a delete of the file. The Buffer tool is used to create the polygons with a distance of 500 feet. A string is used to print that the polygons have been created. The eighth process is a Spatial Join which adds the fields from the no match county buffer to the state points that are within the polygons, using the keep common parameter. The ninth process is to select the records where the Global ID field of the state points equal the Global ID field of the added buffer polygon. The result contains only the three records from the state feature class that didn't match in the first near analysis.

11 If Exists, Delete Buffer Analysis Print Completed String If Exists, Delete Spatial Join Analysis Print Result using Get Count If Exists, Delete Select where Global ID Matches Buffer, Spatial Join & Select

12 Near Analysis & Merge Management The tenth process is to perform a second Near analysis - this time between the no match county points as the target and the three state points just isolated from the buffer, spatial join and select. The eleventh and final process is the preparation of the feature class containing the remaining three records and merging it to the other records that matched in the first near analysis. The Delete Field tool removes the Global ID added from the first Join Field management. And the Join Field tool adds the Global ID of the Near FID from the second Near analysis. The script checks if the merged feature exists and if so, performs a delete of the file. The Merge tool creates the County Final feature class. Print string indicates merge is complete and the script is finished.

13 Near Analysis Print Completed String Delete Field Join Field If Exists, Delete Merge Management Print Completed & Finished String Near Analysis & Merge

14 Python Shell Print Strings

15 Introduction & Set up of Map Script A map was created using three layers of points plus Bing Maps Hybrid as the base map. The layers are the feature class that resulted from the merge named County Final that contains the distance calculation, the state points and the no data points. The modules are imported: arcpy, sys & traceback. From arcpy.mapping import * is used to eliminate the need to write it each time. Paths are set for the datapath, mappath and the map document. The data frame is specified and the layers in the table of contents are retrieved with a loop. A print string is used to list the layers. An if, else is used to assign a variable to the county data layer and a print string is used to indicate which layers were or were not assigned (a variable) for search. A search cursor is created with the county data variable.

16 Import Modules Set Paths & Get Map Document Get Data Frame Get List of Layers in Table of Contents Loop through Layers Assign Layer to Variable Create Search Cursor Introduction & Set up Map Script

17 Set up (cont.) & PDF Export A for loop is used to loop through the individual rows. A variable is set to the facility name field. A query variable is set and assigned to the layer definition query property. Using the get extent method, the data frame's extent property is set to the layer's extent. Pans and centers the data frame extent using a new extent object. The data frame scale is set at 1:2,000. Check to see if the PDF file exists, and if so, deletes it. The export to PDF routine exports the maps, using the mappath variable plus the facility variable to name the files. Print string showing PDF created and completed for each facility.

18 Create For Loop Set Name Field Variable Create Query Variable Assign Layer Definition Set Data Frame Extent Pan to Extent Set Scale If Exists, Delete Export to PDF Set up (cont.) & PDF Export


Download ppt "Introduction to GIS Programming Final Project Submitted by Todd Lenkin Geography 375 Spring of 2011 American River College."

Similar presentations


Ads by Google