Professional Documents
Culture Documents
Ex 4
Ex 4
The city of Providence, Rhode Island is increasing their infrastructure to improve local economy.
They have received a map of industrial buildings and highways for the county of Providence. They
have received schools and sewer line data for the state of Rhode Island. As the GIS manager, you
have been asked to finish the map by completing the following tasks:
Clip the schools and sewer line data using the Providence county border.
Change the map labels for the highways layer.
To complete the exercise, you need to download the data. If you have already downloaded and
installed the data, continue to the next step.
First, you will open the map document provided by the city of Providence.
Open ArcMap.
Close the Catalog window—you will not need it for this exercise.
Now that the map is set up, your next step is to use the Clip tool to clip the schools feature
class using the Providence boundary.
Double-click Clip.
Click Save.
Click OK.
Instead of repeating these same steps to clip the sewer data, you will use Python to repeat this
task.
There are several ways to use Python to re-run the Clip tool. In this step, you will use a Python
snippet.
Right-click Clip, and then choose Copy As Python Snippet (as shown).
The Python Snippet translates the Clip tool into Python code—in particular, a function. The
syntax begins with the site package (arcpy), then is followed by the function (Clip_analysis). The
function parameters are the same parameters as the tool (Input Features, Clip Features, Output
Feature Class, and XY Tolerance).
Note: When you want to skip an optional parameter or keep its default setting, you
can exclude it from the Python syntax, or add an empty set of quotation marks (" ")
or a pound sign ("#"). In this case, the Python snippet uses a pound sign to
indicate that the XY Tolerance is empty.
The Python Snippet needs to be edited to execute Clip on the sewer feature class.
Input Features
Clip Features
XY Tolerance
Note: Because you are still working with feature layers in your map, you do not
need to define the full path of RI_Sewers. If you were working outside ArcMap or
with a feature class that was not a feature layer, you would need to define the full
path for this parameter
"C:/Student/PythEveryone10_1/PythonInArcGIS/RhodeIsland.gdb/RI_Sewers".
Change the feature class name of the Output Feature Class parameter to Sewers.
You do not need to change the full path of the Output Feature Class because you want to save
the Output Feature Class to the same geodatabase as your other data. This is why you've only
changed the feature class name.
Click at the end of the line of code, outside the closing parenthesis.
The Clip_analysis function executes and the new Sewers layer is added to the map document.
The next task is to update the highway labels. First, you will reformat the map document to
better see the labels.
The highway labels currently show the highway number. You will use Python to manipulate the
label expression to display the word Highway before the highway number (e.g., Highway 101).
The label expression allows you to alter how a label is displayed, without having to change the
field values in the attribute table. Currently, the Highways label expression is [HWY_SYMBOL],
which represents each of the highway numbers.
Using Python, how would you concatenate "Highway " with the [HWY_SYMBOL]
field?
Click Verify.
In the Expression Verification dialog box, confirm that the Sample Label reads Highway
100.
Click OK to close the Expression Verification and Label Expression dialog boxes.
Click OK to close the Layer Properties dialog box, which will update the label expression.
Now that the labels have been updated, your final step is to set up the map layout.
First, you need to add a map layer that will serve as a geographic reference for those viewing the
map.
On the Standard toolbar, click the arrow next to the Add Data button and choose Add
Basemap.
The Basemap Gallery displays basemaps that are available on ArcGIS Online.
Select the Light Gray Canvas basemap, and then click Add.
Your map document displays the new basemap layer below the other map layers.
The map document is complete and ready for the city of Providence to use for their infrastructure
planning project.
Close ArcMap.