Friday, August 4, 2017

Module 11

Sharing Tools

The final module for GIS Programming 5103 ended with an introduction to sharing tools.

There are three ways that a tool can be shared.  

1. The first method is compressing the original folder structure using a ZIP file. This ZIP file can then be emailed or posted online.

2. The second method involves users having access to the same local network. The folder containing the file structure can be copied into the folder accessible to all users.

3. The third method is to publish the toolbox as a geoprocessing service using ArcGIS.

The final modules assignment involved working with a created toolbox and a completed script tool. The tool was edited and updated in ArcMap and the script was embedded into the tool and password protected. The toolbox was then submitted with no other files.

Below are screenshots of the final product. The tool dialog box was created from the provided script. The purpose of the script/tool is to create randomly placed points inside of a feature, then create buffers around those points.The results include the boundary feature, random points and buffers.
Tool dialog box
Results of running the tool dialog box.

Thursday, July 27, 2017

Module 10

Creating Custom Tools

Module 10 focused on turning Python scripts into tools in ArcMap. Creating tools out of Python scripts can be very beneficial for other users who may utilize your script. Once the Python script becomes a tool it can be accessed through the Catalog and Search windows in ArcMap.

Below is a brief description of how to create a custom tool out of a Python script.

1.     Create the Python script and then create the toolbox in ArcMap that will contain the script.
2.     Add the script to the toolbox and include name,description, and ensure that the “Store relative path names” option is checked.
3.     Set the parameters for the tool, such as the input file location and output file locations.
4.     Return to the Python script to edit the file paths with the corresponding parameter in the tool using the arcpy.GetParameter(#).
5.      To ensure that the script is running correctly utilize the tool dialog box in ArcMap. Open the script for editing and add the arcpy.AddMessage() so that the print messages appear in the ArcMap tool dialog box.
6.     Run the tool in ArcMap.
For the Module 10 assignment we had to create a custom tool out of a provided script. This entailed setting the tool parameters and setting the parameters in the script.
Below are two screen shots from the Module 10 assignment.
Screen shot of the script tool window

Screen shot of the tool dialog box displaying printed messages.

Monday, July 24, 2017

Module 9: Working with Rasters

Working with Rasters

For module 9 we were introduced to working with raster data type.  This included utilizing ArcPy functions such as creating a raster list and describing raster properties. Module 9 also included working with Spatial Analyst to manipulate raster data.

The module 9 assignment involved creating a raster output that identifies areas with a particular set of parameters. We reclassified the landcover type and identified Slope that was between 5 - 20° and Aspect between 150 - 270°.
Raster output that meets required slope,aspect, and land classification parameters

Sunday, July 16, 2017

Module 8

Module 8: Working with Geometries

For module 8 we were introduced to working with geometries. Our assignment was to create a script that creates a .txt file from a shapefile. The .txt file includes the object Id, vertex number, coordinates, and the stream name.

Initially I had a issues creating a string that would designate the stream name. Each script would produce a text file that ended with NAME. After looking through my script I realized that when I created the Search Cursor the NAME field was the 2nd row. Understanding how to create a line in the text file using the .write() method in relation to the fields created in the Search Cursor helped.

Text file of object IDs, coordinates, and stream names.

Saturday, July 8, 2017


Module 7: Exploring and Manipulating Spatial Data

For this weeks assignment we were introduced to exploring spatial data and the ArcPy data access module arcpy.da. Through out this module we worked with data in a variety of ways. The first half involved an introduction to ways in which you can check for the existence of data, describe data, list data, and use list in for loops.

An important focus was working with dictionaries. Dictionaries enable pairs of data to be grouped based on corresponding values from another table. A dictionary is made up of a {"keys":"values"}

An example of a dictionary would be {"North Carolina":"Wilmington"}

The second half of the module involved working with cursors to access data, and using SQL in Python.

Part 1 of the script results
This modules lab assignment involved creating a new geodatabase, copying all data from my Data folder in the new geodatabase, and populating a dictionary with the names and population of every "County Seat" city in New Mexico.

Part 2 of the script results
Process Flow Diagram

Sunday, June 25, 2017

Module 6

Geoprocessing with Python

For Module 6 we were introduced to Geoprocessing with Python which allows for creating script in Python that can be integrated into ArcMap.  The first step is to import ArcPy as the first line of code and set the active workspace. These steps will allow the user to integrate Geoprocessing tools into the script. The tool name and toolbox alias is required to integrate Geoprocessing tools into Python.

Geoprocessing tools can be assessed using two different lines of syntax.

1. arcpy.<toolname_toolboxalias>(<parameters>)
2. arcpy.<toolboxalias>.<toolname>(<parameters>) 

Along with system toolboxes, custom toolboxes can also be accessed in Python, but the custom toolbox must be imported.

This weeks assignment entailed importing ArcPy, adding XY coordinates using the AddXY tool, creating a Buffer with the Buffer tool and Dissolving the buffer into single features using the Dissolve tool. Once each task was performed a message was printed utilizing the GetMessages() function
The screen cap shows the printed message after each Geoprocessing tool was ran.

Flowchart of my script that adds XY coordinates, creates 1000 meter buffer, and dissolves the hospital buffer.


Sunday, June 18, 2017

Module 5

Module 5 Geoprocessing in ArcGis

Module 5 introduced the very useful concepts of working with Geoprocessing tools, creating models, and utilizing scripts within ArcGIS. The assignment for this week consisted of creating a toolbox, creating a tool using  ModelBuilder, export a script from ModelBuilder, creating a model-derived script to work outside of ArcMap, and creating a script tool. 

The most useful tool I found was the ability to first create a Model using ModelBuilder in ArcMap and then exporting the model into a script. The script will need several adjustments before it can be ran properly, but using the visual aid of ModelBuilder can help assist in creating a text based script.

Flow chart of ModelBuilder that removes "Not prime farmland"
from the clipped soil shapefile.
The first assignment was creating a model in ModelBuilder. The Clip Tool, Select Tool, and the Erase Tool were utilized. Utilizing these three tools clipped one shapefile into another then selected all soils that did not meet the criteria using a SQL expression. The erased tool was then used to remove the items from the shapefile.

The tool was then exported to a Python script. Several small changes needed to be made in order for the script to run properly. The script was then made into a script tool within ArcToolbox.
Final Result Featured "Not prime farmland" Removed