Wednesday, November 12, 2014

Using Python Script to Run ArcGIS Operations

This is an ongoing blog post to be completed by the end of the semester.

Background:

Goal:

The objective of completing these blogs is to learn how to use Python code in GIS applications. Specifically how to use the ArcPy extension. Python coding will be used throughout GIS II class to run several different tasks. These exercises should help the class become well versed in using Python coding for geospatial applications by the end of the class.

Exercise 5:  Preparing Rasters for Further Analysis



In exercise 5 it was required to prepare the various rasters that had been downloaded for analysis that will be performed in later portions of the project.  The rasters first all had to be moved into the same folder as the geodatabase for ease of the coding process.  The first step in the actual coding was to set the environments to the folder that had been created.  From there the rasters had to be picked out of the folder using the ListOfRasters command.  Afterward the rasters were projected to the correct projection of Trempealeau County using arcpy.ProjectRaster_management.  Then the rasters were extracted to the outline of the Trempealeau County boundary using extract by mask.  The final task was simply to import the rasters into the Trempealeau County geodatabase.


Exercise 7:  Selecting out the Desired Mines



For exercise 7 it was required to query out and export the correct mines based on several categories.  The mines feature class that was given contained all mine facilities in Wisconsin given by the DNR.  These facilities included processing facilities and other administrative facilities that aren't needed to run the network analysis.  The objective of exercise 7 was to run network analysis to find routes the trucks have to take and the cost of using these routes between mine facilities rail nodes.

The first step as always was to set the default environments.  In this case the default work space was set to the exercise 7 geodatabase where all the feature classes were contained.  From here variables were established to represent the various existing feature classes, the step-between feature classes, and the final feature class.  Then the SQL statements were written and run using arcpy.MakeFeatureLayer_management to query out the desired mines.  The qualities that were used were mines with an active status, with a facility type like "Mine", and not with a facility type like "Rail".  The mines that have rail in their facility type were queried out due to these having their own rail spurs.  Then the mines desired were selected by location, intersecting Wisconsin and not within 1.5 kilometers of a railroad.  The selected features were then copied over to the geodatabase.

No comments:

Post a Comment