Thursday, April 14, 2016

Exercise 7: Python Script

The goal of this python script was to create a new feature class based off of already existing features and attributes that were provided. This new feature class needed to fit certain criteria and complete certain objectives at the end. In this part we were expected to prepare the data that was given to us for network analysis by writing our python script so than it would select the mines that are needed for our analysis. 


There was certain criteria that the python script needed to meet, the criteria is listed below;

1. The mine must be active

2. The mine must not also have a rail loading station on-site

3. The mine cannot be within 1.5 kilometers of the railroads. 

There was also five objectives that needed to be met in order for the python script to be correctly written, the objectives are as listed below; 

1. Set up your script

2. Set up the variables

3. Write several SQL statements to select the mines based on the above criteria

4. Use the query statement to run the queries

5. Select all mines that are within 1.5 km from a rail road and remove them from your mines


Once we had all of the criteria and objectives in mind we could know start the script after setting up the connection for the geodatabase where we will find all of the data that we need to use for this project. Then we created a name for each of the variables that we needed to use in the script so than it would be more easily read by the program. The next step was to set up SQL statements so than we would be able to select the mines that are both being active and that do not have a railroad on site. Then we needed to select the mines that were not within 1.5 km of a railroad. After writing the script and running it, my final output came out to 44 mines that were not within 1.5 km of a railroad. Once everything was complete, we opened up ArcMap and looked at the new feature class that was just located. After viewing the new feature class and looking at all of the data that was present it was clear that the data appeared correct and accurate. Below is figure 1 which is an image of the script that was created for this project. 

Figure 1: Python Script 

No comments:

Post a Comment