Professional Documents
Culture Documents
File-439742875-439742875 ArcPyLab 2123286428607349
File-439742875-439742875 ArcPyLab 2123286428607349
Getting Started
Open a New Project in ArcMap and import the datasets ‘PopulatedPlaces’ and ‘Airports’. It is
best to put these feature classes inside the Default geodatabase associated with your project.
When testing the code remember to ‘clear selection’. Otherwise, the tool will run only on the
selected features.
Hints:
1. You might want to set your ArcPy environment to allow overwrites of files (if you plan
on testing your script a few times).
2. You have been provided the two shapefiles necessary to do this assignment. Make sure
that both files use the same spatial reference. Given that you’ll need to specify the
search radius (buffer) in meters, you’ll want to make sure that both shapefiles are in an
appropriate spatial reference that uses meters.
a. Tip: WKID 3857 WGS_1984_Web_Mercator_Auxiliary_Sphere is a good option.
b. Create a function that does the projection and returns the name of the projected
file. Then call this function for both shapefile user inputs. This is the optimal
solution.
3. Use buffer analysis to buffer the cities by the user-specified radius and create a new
shapefile.
4. Use Select Layer By Location analysis or Select Layer By Attribute analysis to do the
intersect and subsetting by country respectively.
Part 2: Create a Geoprocessing script tool (8 points)
Convert the above code into a Geoprocessing Script tool. This part is meant to be done
primarily through self-exploration and learning. We have provided the resources you will need
in the “practice resources”. However, since this is the last piece of deliverable in the entire
course, we expect you to be able to solve problems independently, specially when it comes to
modifying code to fit a particular program interface. Thus, step-by-step instructions are not
provided.
1. Create a new toolbox in ArcToolbox and call it YourName_ArcPyLab.tbx
2. Copy your Notebook code into a file with a .py extension.
3. The tool should accept as input the following parameters:
a. Workspace: remember to set filter as Workspace > Local database
b. Country Name: String
c. Buffer Distance: Long
4. Change all of the user-input functions to arcpy.GetParameterAsText(<index>)
5. Change all of your print statements to arcpy.AddMessage(<statement>)
6. The output of the tool should be text in the form of messages in same format as above.
Submission
Submit both your Python Notebook and the Toolbox