-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLongProExistingVsProposed
More file actions
44 lines (31 loc) · 2.11 KB
/
LongProExistingVsProposed
File metadata and controls
44 lines (31 loc) · 2.11 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import arcpy
#make sure to iterate over zones if you have multiple lines!
# Allow overwriting outputs
arcpy.env.overwriteOutput = True
# Inputs - update as needed
line_feature = r"G:\I-L\KootenaiKTOI\GIS\Feature_Data\Nimz\Geum090924_NimzChannelLines\Nimz_ChannelDeepeningLines_0924.shp"
#this is the line from which you want to extract the longitudinal profile
raster_a = r"G:\I-L\KootenaiKTOI\GIS\Elevation_Data\Nimz\LiDAR_Topobath2017-Nimz2021_NV5_UTM11NF.tif"
#surface #1, in this case, existing
raster_b = r"G:\I-L\KootenaiKTOI\GIS\ArcPro\Nimz_Base_Mapping.gdb\ProposedSurfaceMosaic20250125"
#surface #2, in this case, proposed
selected_lines = r"G:\I-L\KootenaiKTOI\GIS\ArcPro\Nimz_Base_Mapping.gdb\SelectedLines"
#this is included because the line feature has multiple attributes
output_points = r"G:\I-L\KootenaiKTOI\GIS\ArcPro\Nimz_Base_Mapping.gdb\GeneratedPoints"
#UPDATE each time if you have mutliple longpros you are making across multiple attributes
output_csv = r"G:\I-L\KootenaiKTOI\GIS\Elevation_Data\Nimz\NimzChannelsLongPro_202501\NimzChannelB1.csv"
#UPDATE each time if you have mutliple longpros you are making!
arcpy.management.MakeFeatureLayer(line_feature, "line_layer")
arcpy.management.SelectLayerByAttribute("line_layer", "NEW_SELECTION", "Zone = 'B1'")
selected_count = arcpy.management.GetCount("line_layer")[0]
if int(selected_count) == 0:
raise ValueError("No features match the query 'Zone'. Check the field name and values.")
print(f"Selected features: {selected_count}")
arcpy.management.CopyFeatures("line_layer", selected_lines)
arcpy.management.GeneratePointsAlongLines(selected_lines, output_points, "DISTANCE", Distance="1 Meters")
arcpy.sa.ExtractMultiValuesToPoints(output_points, [[raster_a, "Raster_A"], [raster_b, "Raster_B"]])
#UPDATE each time if you have mutliple longpros you are making!
arcpy.conversion.TableToTable(output_points, r"G:\I-L\KootenaiKTOI\GIS\Elevation_Data\Nimz\NimzChannelsLongPro_202501", "NimzChannelB1.csv")
print(f"Selected lines saved to {selected_lines}")
print(f"Points and raster values saved to {output_points}")
print(f"Table exported to {output_csv}")