-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask2.py
More file actions
25 lines (17 loc) · 827 Bytes
/
Task2.py
File metadata and controls
25 lines (17 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import arcpy
# Set workspace
arcpy.env.workspace = 'V:/ENV859_PS4/Data'
# Allow us to overwrite output
arcpy.env.overwriteOutput = True
# Creates a string variable containing the path to the Roads.shp feature class
Roads = "V:\ENV859_PS4\Data\Roads.shp"
# Creates a string variable with the value “0;201;203” (i.e. a “multi-value string”) of the road type class values to be processed.
RoadValues = "0;201;203"
# Splitting RoadValues between semi-colons to create a list variable
ValueList = RoadValues.split(";")
# Loop through each road type value in ValueList
for i in ValueList:
# Define output fc to write using ValueList item
out_feature_class = "V:/ENV859_PS4/Scratch/roads_{}.shp".format(i)
# Select analysis
arcpy.analysis.Select(Roads, out_feature_class, f'"ROAD_TYPE" = {i}')