Last active
June 29, 2023 12:18
-
-
Save rabbleNaut/9663452 to your computer and use it in GitHub Desktop.
This was for a Scripting for GIS class project using Arcmap 10.1 and Model Builder
This file contains 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
'''=============================== | |
ClipLooper.py | |
The purpose of this script is to step through all 10 counties in the dataset and | |
clip each of the 3 features (Water Bodies, Streams, City Limits) to the counties border. | |
Script Arguments: | |
0 - Input County FC | |
1 - Input Water Bodies FC | |
2 - Input Streams FC | |
3 - Input Cities FC | |
4 - Workspace | |
Rob Abbey | |
12/1/2013 | |
GISC 2250, Mini Project C | |
ArcGIS ver. 10.1, Python ver. 2.7 | |
==================================''' | |
import arcpy, os | |
from arcpy import env | |
# Get input parameters | |
countyFC = arcpy.GetParameterAsText(0) | |
waterFeatures = arcpy.GetParameterAsText(1) | |
streamFeatures = arcpy.GetParameterAsText(2) | |
cityFeatures = arcpy.GetParameterAsText(3) | |
# Sets workspace | |
env.workspace = arcpy.GetParameterAsText(4) | |
# Allows the output features to be overwritten | |
env.overwriteOutput = True | |
# Sets spatial reference (WGS_1984_UTM_Zone_14N) | |
sr = arcpy.SpatialReference(32614) | |
# Allows fields to be extracted from Counties Feature Class | |
rows = arcpy.SearchCursor(countyFC, "", "", "NAME; Shape", "") | |
# Iterates through each feature in Counties Feature Class | |
for row in rows: | |
# Sets the clip feature | |
feat = row.Shape | |
# Creates new feature dataset based on current county name | |
outputFDS = arcpy.CreateFeatureDataset_management(env.workspace,row.name,sr) | |
# Defines output feature class, prints message to console, runs clip tool | |
outputWater = str(outputFDS) + os.sep + row.name + "_" + str(waterFeatures) | |
arcpy.AddWarning ("Now creating feature class: %s" % outputWater) | |
arcpy.Clip_analysis(waterFeatures, feat, outputWater) | |
outputStreams = str(outputFDS) + os.sep + row.name + "_" + str(streamFeatures) | |
arcpy.AddWarning ("Now creating feature class: %s" % outputStreams) | |
arcpy.Clip_analysis(streamFeatures, feat, outputStreams) | |
outputCities = str(outputFDS) + os.sep + row.name + "_" + str(cityFeatures) | |
arcpy.AddWarning ("Now creating feature class: %s\n" % outputCities) | |
arcpy.Clip_analysis(cityFeatures, feat, outputCities) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment