Hey everyone, the ESRI Community has been really helpful and would not be as far as I am with this code with you. I do need help with this last bit though.
So the goal of this tool/code is to take the "Lines_Selected" line feature class and divide it up into two line feature classes based on their spatial relationship to my point feature classes.
The Lines_Selected feature class is created in the ForDeveloping.gdb and added to the map frame.
After this is done I want to divide it into two feature classes, based on the lines' spatial relationship to the point feature classes located in the NewHydrant.gdb. They should be called Kuna4WS_StreetsExtracted and Middleton4WS_StreetsExtracted.
However the code I currently have just copies the Lines_Selected feature class from the map frame and saves it in the NewHydrants.gdb, which isn't what I'm wanting. Here is the code that I am using, any help or suggestions is greatly appreciated, thank you!
import arcpy
import os
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r"C:\UpdateDevelopmentPython\ForDeveloping\ForDeveloping.gdb"
EnterWaterSysID = arcpy.GetParameterAsText(0).split(";")
Hydrant_FC = "Hydrants"
WaterSystems = "WaterSystems"
Streetmap = r"C:\UpdateDevelopmentPython\Streetmap Premium\FGDB\StreetMap_Data\NorthAmerica.gdb\Routing\Routing_ND"
qry = "{0} IN ({1})".format(arcpy.AddFieldDelimiters(datasource= Hydrant_FC, field = 'WaterSysID'), ', '.join(EnterWaterSysID))
arcpy.SelectLayerByAttribute_management(in_layer_or_view=Hydrant_FC, where_clause=qry)
arcpy.SelectLayerByLocation_management(Hydrant_FC,"Within",WaterSystems,None,"SUBSET_SELECTION","INVERT")
arcpy.env.workspace = r"C:\UpdateDevelopmentPython\ForDeveloping\ForDeveloping.gdb"
Service_Area = arcpy.na.MakeServiceAreaAnalysisLayer(network_data_source=Streetmap,
layer_name="Service Area",
travel_mode="Driving Distance",
travel_direction="FROM_FACILITIES",
cutoffs=[0.189394],
time_of_day="",
time_zone="LOCAL_TIME_AT_LOCATIONS",
output_type="LINES",
polygon_detail="STANDARD",
geometry_at_overlaps="SPLIT",
geometry_at_cutoffs="RINGS",
polygon_trim_distance="100 Meters",
exclude_sources_from_polygon_generation=[],
accumulate_attributes=["Miles"],
ignore_invalid_locations="SKIP")[0]
Updated_Service_Area = arcpy.na.AddLocations(in_network_analysis_layer=Service_Area,
sub_layer="Facilities",
in_table=Hydrant_FC,
field_mappings="",
search_tolerance="5000 Meters",
sort_field="",
search_criteria=[["Routing_Streets", "SHAPE"],
["Routing_Streets_Override", "NONE"],
["Routing_ND_Junctions", "NONE"]],
match_type="MATCH_TO_CLOSEST",
append="APPEND",
snap_to_position_along_network="NO_SNAP",
snap_offset="5 Meters",
exclude_restricted_elements="EXCLUDE",
search_query=[])[0]
Solve_Succeeded = arcpy.na.Solve(in_network_analysis_layer=Updated_Service_Area,
ignore_invalids="SKIP",
terminate_on_solve_error="TERMINATE",
simplification_tolerance="",
overrides="")
Lines = arcpy.Select_analysis("Lines","Lines_Selected")
arcpy.SelectLayerByAttribute_management(Hydrant_FC, "CLEAR_SELECTION")
Lines_Extracted = r"C:\UpdateDevelopmentPython\ForDeveloping\ForDeveloping.gdb\Lines_Selected"
p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps("Map")[0]
m.addDataFromPath(Lines_Extracted)
gdb = r"C:\UpdateDevelopmentPython\ForDeveloping\NewHydrants.gdb"
HydrantLines = arcpy.ListFeatureClasses()
for fc in HydrantLines:
desc = arcpy.da.Describe(fc)
HydrantFeatures = os.path.join(gdb,desc["baseName"])
arcpy.MakeFeatureLayer_management(fc,HydrantFeatures)
arcpy.SelectLayerByLocation_management("Lines_Selected","WITHIN_A_DISTANCE",HydrantFeatures,"1000 Feet")
HydrantPoints = arcpy.ListFeatureClasses()
for fcs in HydrantPoints:
desc1 = arcpy.da.Describe(fcs)
arcpy.SpatialJoin_analysis("Lines_Selected",fcs, HydrantFeatures)
arcpy.Copy_management("Lines_Selected",HydrantFeatures)