top of page

Python for ArcGIS

Screenshot 2026-03-08 232505.png

This project used ArcPy automation in Python to model hydroline  interactions with surrounding infrastructure and environmental features. A scripted workflow was developed to identify intersections with roads, streams, and trails, merge intersections, and export  results for further analysis.

Project Workflow

Step 01

Identify Hydroline Interactions with Surrounding Features

Hydroline infrastructure was intersected with nearby linear features (roads, streams, and trails) using ArcPy to identify locations where the right-of-way interacts with existing landscape elements.

S1_feature = ['roads', 'streams', 'trails']

for feature in S1_feature:
output_name = "HL_" + feature + "_intersect"
arcpy.Intersect_analysis([feature, 'hydroline'], output_name, output_type="POINT")

Step 02

Attribute Affected Features

New attribute fields were added to each intersected dataset to identify the feature type and assign a unique identifier to each affected location.

arcpy.management.AddField(output_name, "affected_name", "TEXT")
arcpy.management.AddField(output_name, "affected_id", "DOUBLE")

with arcpy.da.UpdateCursor(output_name, ["affected_name", "affected_id"]) as cursor:
id_counter = 1
for row in cursor:
row[0] = feature
row[1] = id_counter
cursor.updateRow(row)
id_counter += 1

Step 03

Combine Affected Features into a Single Dataset

All intersected feature layers were merged into one dataset to create a consolidated record of all hydroline interactions with surrounding infrastructure and landscape features.

intersects = ["HL_streams_intersect", "HL_trails_intersect", "HL_roads_intersect"]

merged_affected = "merge_affected"
arcpy.management.Merge(intersects, merged_affected)

Step 04

Prepare Results for Export and Reporting

Spatial coordinates were extracted from the merged dataset and stored as latitude and longitude fields before exporting the final results to an Excel table for reporting and further analysis.

arcpy.AddField_management(merged_affected, "Latitude", "DOUBLE")
arcpy.AddField_management(merged_affected, "Longitude", "DOUBLE")

with arcpy.da.UpdateCursor(merged_affected, ["SHAPE@XY", "Latitude", "Longitude"]) as cursor:
for row in cursor:
x, y = row[0]
row[1] = y
row[2] = x
cursor.updateRow(row)

arcpy.conversion.TableToExcel(
merged_affected,
r"...\merge_affected.xlsx"
)

bottom of page