1

I'm running the Make Service Area tool in ArcPy and every time it creates a feature dataset in my gdb named "ServiceAreaSolver1xxxxxx." I've ignored them but they are taking up space and are annoying to scroll through. I now have several dozen in my gdb. I'm not sure what they're for.

Is my code missing something to delete this at the end of the process?

enter image description here


new = arcpy.na.MakeServiceAreaAnalysisLayer('network','layer',
                                           travel_mode="Walking Time",
                                           travel_direction="Away from facilities",
                                           cutoffs=[5],
                                           output_type="POLYGONS",
                                           polygon_detail="HIGH",
                                           geometry_at_overlaps='DISSOLVE',
                                           polygon_trim_distance='100 Feet')



layer_object = new.getOutput(0)

sublayer_names = arcpy.na.GetNAClassNames(layer_object)

facilities_layer_name = sublayer_names["Facilities"]

arcpy.na.AddLocations(layer_object, facilities_layer_name, facilities, "","")

arcpy.na.Solve(layer_object)

polygons_sublayer = arcpy.na.GetNASublayer(layer_object, "SAPolygons")

arcpy.conversion.FeatureClassToFeatureClass(polygons_sublayer,outLocation,'layername')
2
  • 1
    Please Edit the Question to contain the code you are asking about.
    – Vince
    Commented Jan 30, 2023 at 5:27
  • As per the Tour there should be only one question asked per question.
    – PolyGeo
    Commented Jan 30, 2023 at 8:22

1 Answer 1

0

Network Analysis names all the datasets 'ServiceArea###'. You can run a cleanup with something like this:

dataSets = arcpy.ListDatasets("ServiceArea*", "All")
if dataSets:
    for ds in dataSets:
        # need to delete what is inside the dataset
        for fc in arcpy.ListFeatureClasses(feature_dataset=ds):
            arcpy.management.Delete(fc)
        # before you can delete the dataset
        arcpy.management.Delete(ds)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.