Last active
August 29, 2015 14:15
-
-
Save donfleming/a8f81f5bced8152beefe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy, os | |
from arcpy import env | |
# Set the workspace and allow overwriting | |
env.workspace = "yourfilepath/output" | |
env.overwriteOutput = True | |
# Set local variables for the state | |
states = "yourfilepath/tlgdb_2014_a_us_nationgeo.gdb/State" | |
roads = "yourfilepath/tlgdb_2014_a_us_roads.gdb/Roads" | |
# Create a search cursor on the states feature class | |
# with the data access module of arcpy. | |
with arcpy.da.SearchCursor(states, ("NAME", "SHAPE@")) as state_cursor: | |
# And now iterate through every state and perform the clip operation | |
for state in state_cursor: | |
name = state[0] | |
geom = state[1] | |
outPoly = os.path.join(env.workspace, name + "_rds") | |
arcpy.Clip_analysis(roads, geom, outPoly) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment