ArcPy help

422
1
07-12-2018 06:22 AM
JeremySingh1
New Contributor II

Hello I seem to be running into an issue where when i run this code in an IDE such as pycharm the code run successfully however it doesnt seem to create any service area or polygons. I do have all the necessary licenses and I am using the correct interpreter. *This code does work in the python window in ArcPro.

Any solutions?? Thanks

import arcpy

print ("Enter Workspace path :")
workspace=input()
arcpy.env.workspace = workspace 

print("running")

arcpy.na.MakeServiceAreaAnalysisLayer("https://www.arcgis.com/", "Service Area", "Driving Time", "FROM_FACILITIES", "5;10;15", None, "LOCAL_TIME_AT_LOCATIONS", "POLYGONS", "STANDARD", "OVERLAP", "RINGS", "100 Meters", None, None)

arcpy.na.AddLocations("Service Area", "Facilities", "Site", "Name Location #;CurbApproach # 0;Attr_Minutes # 0;Attr_TravelTime # 0;Attr_Miles # 0;Attr_Kilometers # 0;Attr_TimeAt1KPH # 0;Attr_WalkTime # 0;Attr_TruckMinutes # 0;Attr_TruckTravelTime # 0;Breaks_Minutes # #;Breaks_TravelTime # #;Breaks_Miles # #;Breaks_Kilometers # #;Breaks_TimeAt1KPH # #;Breaks_WalkTime # #;Breaks_TruckMinutes # #;Breaks_TruckTravelTime # #", "5000 Meters", None, None, "MATCH_TO_CLOSEST", "APPEND", "NO_SNAP", "5 Meters", "EXCLUDE", None)

arcpy.na.Solve("Service Area", "SKIP", "TERMINATE", None, None)

print("DT Ended")

0 Kudos
1 Reply
MelindaMorang
Esri Regular Contributor

Hello Jeremy.  What you're doing here is creating a service area layer object, adding locations to it, and solving it.  However, you are not doing anything in your script to write out the output anywhere.  You should either save the Service Area layer out as an lyrx file to disk or extract just the polygons and use Copy Features or Feature Class To Feature Class to save it to disk.

Check out the last two code samples on this page.