Arcpy - GenerateServiceAreas_na throw error when using some parameters

258
2
03-09-2018 10:29 AM
MaximeDemers
Occasional Contributor III

Hi,

I encounter a non-explicit error when using arcpy.GenerateServiceAreas with those parameters:

  • Maximum_Facilities
  • Maximum_Number_of_Breaks

This is how I can reproduce the error:

import arcpy, os

arcpy.env.overwriteOutput = True

featureSet = {
    "geometryType": "esriGeometryPoint",
    "spatialReference": {
        "wkid": 3857,
    },
    "fields": [
        {
            "name": "Name",
            "alias": "Name",
            "type": "esriFieldTypeString"
        },
    ],
    "features" : [
        {
            "geometry" : {
                "x" : -7929427,
                "y" :  5910701
            },
            "attributes" : {
                "Name": "Foo"
            }
        }
    ]
}

facilities = arcpy.AsShape(feature_set, True)

Network_Dataset_Path = os.path.join(r"\\vnageop1", "geod", "Geobase", "Network Analyst", "Reseau routier - AQ.gdb", "NetworkAnalystAQ", "NetworkAnalystAQ_ND")

arcpy.GenerateServiceAreas_na(facilities, "10", "Meters", Network_Dataset_Path, "in_memory/ServiceAreasOutput", Maximum_Facilities=10, Maximum_Number_of_Breaks=5)

The error is the following:

Traceback (most recent call last):
  File "G:\testNA.py", line 34, in <module>
    arcpy.GenerateServiceAreas_na(facilities, "10", "Meters", NA_Path, "in_memory/ServiceAreasOutput", Maximum_Facilities=10)
  File "c:\app\arcgis\desktop10.3\arcpy\arcpy\na.py", line 3878, in GenerateServiceAreas
    raise e
ExecuteError: A python error occurred.
Failed to execute (GenerateServiceAreas).

If I remove the Maximum_Facilities and Maximum_Number_of_Breaks parameters, I have a correct output.

What could be the problem?

0 Kudos
2 Replies
DanPatterson_Retired
MVP Esteemed Contributor

Not available in PRO at all http://pro.arcgis.com/en/pro-app/tool-reference/appendices/unavailable-tools.htm

but you are using 10.3 and apparently trying to set up a 'service' 

http://desktop.arcgis.com/en/arcmap/latest/tools/network-analyst-toolbox/generate-service-areas.htm

Which has some help on the difference between free and paid services

This parameter helps you govern the amount of processing that occurs when solving. For example, you could assign a low value to this parameter for a free version of the service you are creating and use a higher value for a paid-subscription version of the service.

Which might be a problem if you can't set up a paid service.

OH... and one uses a dtype of 'Long' and the other 'String' so check the help for the tool you are using

If you are just doing network analyst stuff., then the generate service area tool help suggests using

make-service-area-layer tool instead

DeeleshMandloi
Esri Contributor

Hi Maxime,

   I am unable to reproduce the error when running the GenerateServiceAreas tool in ArcMap 10.6 with the same inputs that you have provided. So if are running into an issue, it is quite possible that this was a bug in the tool that was fixed in subsequent releases.

As a workaround, can you try passing the values for Maximum_Facilities and Maximum_Number_of_Breaks parameters as strings instead of integers? 

arcpy.GenerateServiceAreas_na(facilities, "10", "Meters", Network_Dataset_Path, "in_memory/ServiceAreasOutput", Maximum_Facilities="10", Maximum_Number_of_Breaks="5")
0 Kudos