ServiceArea
サマリー
An ArcPy class for performing a service area analysis.
ディスカッション
A service area analysis allows you to calculate the area reachable from one or more facilities within a designated time or distance limit.
Learn more about service area analysis
Learn more about how to perform a network analysis using arcpy.nax
構文
ServiceArea(in_network)
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
in_network |
The network dataset or service that will be used for the network analysis. The argument can be specified using one of the following:
To use a network dataset, the network must have at least one travel mode. To use a portal URL, you must be signed in to the portal with an account that has routing privileges. Learn how to sign in to a portal in Python Learn more about network analysis using routing services When using ArcGIS Online or an ArcGIS Enterprise portal whose routing services are configured using ArcGIS Online as the Learn more about credit consumption and analysis limits in network analysis |
String |
プロパティ
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
accumulateAttributeNames (読み取り/書き込み) |
A list of cost attributes that will be accumulated during analysis. These accumulated attributes are for reference only; the solver only uses the cost attribute used by the designated travel mode when solving the analysis. The default is an empty list. Setting this property returns an error if the network data source is ArcGIS Online or an ArcGIS Enterprise portal that does not support accumulating attributes. |
String |
|
allowAutoRelocate (読み取り/書き込み) |
Specifies whether inputs with existing network location fields can be automatically relocated at solve time to ensure valid, routable location fields for the analysis. If the value is Even if the value is The default is This property affects locating for all input types. To change this property for individual input types, use the Learn more about network location fields and how inputs are located on the network Setting this property returns an error if the network data source is ArcGIS Online, an ArcGIS Enterprise portal that does not support using network location fields, or a portal running a version of ArcGIS Enterprise earlier than 11.0. |
Boolean |
|
allowSaveLayerFile (読み取り/書き込み) |
Specifies whether saving the analysis result as a layer file using the |
Boolean |
|
defaultImpedanceCutoffs (読み取り/書き込み) |
The extent of the service area that will be calculated. The service area output shows the area reachable from the starting facility within this impedance cutoff. The default is an empty list, but at least one cutoff must be specified before solving the service area. If the travel mode used in the analysis uses a time-based impedance attribute, the values for this property are interpreted in the units specified in the The values can be overridden on a per-facility basis by specifying individual cutoff values in the Facilities input data type. This property can be overridden on a per-facility basis using the |
Double |
|
distanceUnits (読み取り/書き込み) |
The units that will be used when reporting the travel distance in the analysis output. Regardless of the units of the cost attributes in the network dataset, the output will be transformed to and reported in the units set in this property. The property is returned and set as a member of the 注意:The |
Object |
|
excludeSourcesFromPolygonGeneration (読み取り/書き込み) |
The list of network dataset edge sources that will be excluded when generating polygons. The property is returned and set as a list of strings in which each list item is the name of the network edge source. The default is an empty list, which means that no edge sources will be excluded from polygon generation. Learn more about excluding edge sources from service area polygon generation |
String |
|
geometryAtCutoff (読み取り/書き込み) |
Specifies the behavior of the output polygons for a single facility when multiple values are specified for the |
Object |
|
geometryAtOverlap (読み取り/書き込み) |
Specifies the behavior of the service area output from multiple facilities in relation to one another. The property is returned and set as a member of the |
Object |
|
ignoreInvalidLocations (読み取り/書き込み) |
Specifies whether invalid input locations will be ignored. A value of レガシー:Routing services based on portals running versions of ArcGIS Enterprise earlier than 10.9 always ignore invalid input locations. The method returns a |
Boolean |
|
networkDataSource (読み取り専用) |
The full catalog path to the network dataset or the URL of the service being used for the analysis. |
String |
|
outputType (読み取り/書き込み) |
The type of output that will be generated for the analysis. Specify polygons, lines, or both. The property is returned and set as a member of the |
Object |
|
overrides (読み取り/書き込み) |
注意:This property is for internal use only. |
String |
|
polygonBufferDistance (読み取り/書き込み) |
The service area polygon trim distance. The polygon trim distance is the distance the service area polygon will extend from the road, similar to a line buffer size. It roughly models how far back from the road centerlines is considered reachable from the road. The trim distance applies only in areas that are not fully surrounded by other reachable roads. Areas fully surrounded by reachable roads will be covered by the service area polygon regardless of the trim distance setting. ヒント:To generate a polygon that includes only the area within the trim distance of reachable roads, configure the service area analysis to output lines instead of polygons and use the Buffer or Pairwise Buffer tool to create simple buffers. The units for the buffer distance value are specified in the |
Double |
|
polygonBufferDistanceUnits (読み取り/書き込み) |
Specifies the units that will be used for the 注意:The |
Object |
|
polygonDetail (読み取り/書き込み) |
Specifies the level of detail that will be used for the output polygons. The property is returned and set as a member of the |
Object |
|
searchQuery (読み取り/書き込み) |
レガシー:This property has been superseded by the When locating inputs on the network, this property specifies a query to restrict the search to a subset of the features in a source feature class. This is useful if you don't want to find features that may be unsuited for a network location. For example, if you don't want to locate on highway ramps, you can define a query to exclude them. The property value is specified as a list with nested lists, with one entry per network source. Each inner list is composed of two values indicating the name of the network source and the SQL expression used as the query for that source. An empty string, For example, the value If a network source is not included in the list, it is interpreted to have no query. The value By default, no query is used for any source. Learn more about locating inputs on the network For more information about SQL syntax, see SQL reference for query expressions used in ArcGIS. Setting this property returns an error if the network data source is ArcGIS Online or a portal running a version of ArcGIS Enterprise earlier than 11.0. |
List |
|
searchSources (読み取り/書き込み) |
When locating inputs on the network, this property specifies the list of network sources that will be used, and, optionally, a query to restrict the search to a subset of the features in a source feature class. The default value is to locate on all network sources except system junctions and override junctions created by running the Dissolve Network tool. By default, no query is used for any source. The property value is specified as a list with nested lists, with at most one entry per network source. Each inner list is composed of two values indicating the name of the network source and the SQL expression used as the query for that source. Possible values for the network source component are the string feature class names of edge and junction sources that participate in the network. Sources in the list will be used for locating, and sources not in the list will not. Queries are useful if you don't want to find features that may be unsuited for a network location. For example, if you don't want to locate on highway ramps, you can define a query to exclude them. For the query component, see SQL reference for query expressions used in ArcGIS for correct syntax. An empty string, For example, the value This property affects locating for all input types. To change this property for individual input types, use the Learn more about locating inputs on the network Setting this property returns an error if the network data source is ArcGIS Online or a portal running a version of ArcGIS Enterprise earlier than 11.0. |
String |
|
searchTolerance (読み取り/書き込み) |
The maximum search distance that will be used when locating the input features on the network. The property is returned and set as a double, and the units of this value are accessed through the This property affects locating for all input types. To change this property for individual input types, use the Learn more about locating inputs on the network レガシー:Setting this property returns an error if the network data source is a portal running a version of ArcGIS Enterprise earlier than 11.0. |
Double |
|
searchToleranceUnits (読み取り/書き込み) |
Specifies the units of the This property affects locating for all input types. To change this property for individual input types, use the レガシー:Setting this property returns an error if the network data source is a portal running a version of ArcGIS Enterprise earlier than 11.0. |
Object |
|
timeOfDay (読み取り/書き込み) |
The date and time of day that will be used for the analysis. The property is specified using a Instead of using a particular date, a day of the week can be specified using the following dates:
For example, to specify that travel should begin at 5:00 p.m. on Tuesday, specify the parameter value as The default is The property will have no impact if the analysis' travel mode's impedance attribute has no time-dependent properties, such as traffic or public transit. Learn more about how dates and times are used and interpreted in a network analysis |
DateTime |
|
timeUnits (読み取り/書き込み) |
Specifies the units that will be used when reporting the travel time in the analysis output. Regardless of the units of the cost attributes in the network dataset, the outputs will be transformed to and reported in the units set in this property. The property is returned and set as a member of the |
Object |
|
timeZone (読み取り/書き込み) |
Specifies whether the time specified in the |
Object |
|
travelDirection (読み取り/書き込み) |
Specifies the direction of travel with respect to the facilities. The property is returned and set as a member of the If the travel direction is |
Object |
|
travelMode (読み取り/書き込み) |
The travel mode that will be used for the analysis. The value is returned and set as an |
Object |
方法
addFields(input_type, field_description[field_description,...])
Adds custom fields to the designated input class. These fields will be included in the field mapping dictionary created by the fieldMappings method and will also be available for use with the insertCursor method.
Learn more about using custom fields in analysis inputs
| 名前 | 説明 | データ タイプ | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
input_type |
The type of input to which the fields will be added. Set this parameter using the |
Object |
||||||||||||||||||||||||
|
field_description[field_description,...] |
The fields and their properties that will be added to the input class. The value will be constructed as a list of lists with each row containing the following items:
Available field types are as follows:
Only the field name and type are required. Use None as a place holder for any of the other parameters to accept the default or if the parameter does not apply to the specified field type. The method will return an error if the field already exists in the table or if any of the field properties are invalid. レガシー:The |
TEXT |
count(input_type)
Returns the number of rows added for an input type.
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
input_type |
The type of input features to count. Set this parameter using the |
Object |
戻り値
| データ タイプ | 説明 |
|---|---|
|
Integer |
The number of rows. |
fieldMappings(input_type, {use_location_fields}, {list_candidate_fields[list_candidate_fields,...]})
Generates an NAClassFieldMappings dictionary that maps the field names of the input type to arcpy.nax.NAClassFieldMap objects that allow you to map fields from the input data to the properties of the solver. The dictionary can be used as input to the field_mappings argument of the load method.
Learn more about how to use field mappings when loading inputs
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
input_type |
The type of input for which the field mappings will be returned. Set this parameter using the |
Object |
|
use_location_fields (オプション) |
Specifies whether network location fields will be included in the returned field mappings dictionary. Network location fields describe the point on the network where an object is located. You can use network location fields to more precisely control how analysis inputs locate on the network and to save time when calling the Learn more about network location fields and how inputs are located on the network When this argument is set to The default value is False. |
Boolean |
|
list_candidate_fields[list_candidate_fields,...] (オプション) |
Use this parameter to map additional, nondefault fields from the input data to the analysis inputs. For example, if the input feature class contains a field named Specify this parameter as a list of Learn more about best practices for setting up analysis inputs レガシー:If the network data source is an ArcGIS Enterprise portal, the method will return an error if any of the fields specified are of a type that is not supported by the portal version. The default value is None. |
Field |
戻り値
| データ タイプ | 説明 |
|---|---|
|
Dictionary |
An |
fieldNames(input_type, {use_location_fields})
Get a list of field names supported by the specified input type.
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
input_type |
The type of input for which the supported field names are returned. Set this parameter using the |
Object |
|
use_location_fields (オプション) |
Indicates whether network location fields will be included in the returned list of field names. Network location fields describe the point on the network where an object is located. You can use network location fields to more precisely control how your analysis inputs locate on the network and to save time when calling the Learn more about network location fields and how inputs are located on the network When this argument is set to The default value is False. |
Boolean |
戻り値
| データ タイプ | 説明 |
|---|---|
|
String |
A list of field names supported by the specified input type. |
insertCursor(input_type, field_names[field_names,...], {append})
Establishes a write cursor on the specified input type. This cursor can be used to add rows directly to the input.
Learn more about how to insert inputs
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
input_type |
The type of input into which the cursor can be used to insert rows. Set this parameter using the |
Object |
|
field_names[field_names,...] |
A list of field names of the input type whose values you want to set when inserting rows using the cursor. You can get the names of the fields supported by an input type using the Learn more about the fields available for each input type In addition to regular fields, you can also set the geometry of the input using one of the following geometry tokens:
The |
String |
|
append (オプション) |
Specifies whether the features being inserted will be appended to the existing set of features for the input type. A value of The default value is True. |
Boolean |
戻り値
| データ タイプ | 説明 |
|---|---|
|
Object |
A |
load(input_type, features, {field_mappings}, {append}, {max_features})
Sets input features to use for the analysis.
Learn more about how to load inputs
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
input_type |
The type of input feature that will be loaded. Set this parameter using the |
Object |
|
features |
The input features that will be loaded. This parameter accepts the following input types:
For layer inputs, only selected features will be loaded. If a layer has a definition query, only the subset of features visible with the definition query will be loaded. The method also honors the Extent geoprocessing environment; only features in the specified extent will be loaded. |
String |
|
field_mappings (オプション) |
An If no field mappings are specified, all fields from the input features that have the same name as the supported fields for the input type will be mapped. Learn more about the fields available for each input type The default value is None. |
Dictionary |
|
append (オプション) |
Specifies whether the features being loaded will be appended to the existing set of features for the input type. A value of The default value is True. |
Boolean |
|
max_features (オプション) |
The maximum number of features that can be loaded into the input type. This is useful if you are creating a tool or service and want an error returned if the size of the input exceeds the available resources. The If no value is provided, no limit will be enforced for the count of the input features. The default value is None. |
Integer |
setLocateSettingsOverrides(input_type, {search_sources[[Source, Expression],...]}, {allow_auto_relocate}, {search_tolerance}, {search_tolerance_units})
Set locate settings for a designated input class, overriding the default locate settings specified for the analysis. This is useful if you want to use different rules to locate different inputs. For example, in an OD cost matrix analysis, you can use a search query that applies to the input origins only, if that query should not apply to the input destinations and barriers.
Using this method, you can override the values of the searchSources, allowAutoRelocate, searchTolerance, and searchToleranceUnits properties for the designated input class.
Learn more about locating inputs on the network
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
input_type |
The type of input for which to override default locate settings. Set this parameter using the |
Object |
|
search_sources[[Source, Expression],...] (オプション) |
The list of network sources to be used when locating inputs of the designated type on the network, and, optionally, a query to restrict the search to a subset of the features within a source feature class. See the documentation for the Specifying a value for this parameter overrides the default If this parameter is not specified or is set to The method returns an error if this parameter is used and the network data source is ArcGIS Online. |
String |
|
allow_auto_relocate (オプション) |
Specifies whether inputs of the designated type with existing network location fields can be automatically relocated at solve time to ensure valid, routable location fields for the analysis. If the value is Even if the value is Specifying a value for this parameter overrides the default If this parameter is not specified or is set to The method returns an error if the network data source is ArcGIS Online. The method returns an error if the network data source is an ArcGIS Enterprise portal that does not support using network location fields. |
Boolean |
|
search_tolerance (オプション) |
The maximum search distance to use when locating inputs of the designated type on the network. Specifying a value for this parameter overrides the default If this parameter is not specified or is set to The units of this parameter value are set using the This parameter does not apply to line and polygon barriers; the method will return an error if this parameter is specified when the |
Double |
|
search_tolerance_units (オプション) |
The units of the maximum search distance when locating inputs of the designated type of the network. The parameter is specified using a member of the Specifying a value for this parameter overrides the default If this parameter is not specified or is set to The value specified using the This parameter does not apply to line and polygon barriers; the method will return an error if this parameter is specified when the |
Double |
solve()
Perform the service area analysis using the properties set on the ServiceArea object and the loaded inputs.
戻り値
| データ タイプ | 説明 |
|---|---|
|
Object |
An |
コードのサンプル
Perform a service area analysis.
# An example showing how to perform service area analysis using a feature class for input facilities.
import arcpy
nds = "C:/data/NorthAmerica.gdb/Routing/Routing_ND"
nd_layer_name = "Routing_ND"
input_facilities = "C:/data/io.gdb/Facilities"
output_polygons = "C:/data/io.gdb/ServiceAreaPolygons"
# Create a network dataset layer and get the desired travel mode for analysis
arcpy.nax.MakeNetworkDatasetLayer(nds, nd_layer_name)
nd_travel_modes = arcpy.nax.GetTravelModes(nd_layer_name)
travel_mode = nd_travel_modes["Driving Time"]
# Instantiate a ServiceArea solver object
service_area = arcpy.nax.ServiceArea(nd_layer_name)
# Set properties
service_area.timeUnits = arcpy.nax.TimeUnits.Minutes
service_area.defaultImpedanceCutoffs = [5, 10, 15]
service_area.travelMode = travel_mode
service_area.outputType = arcpy.nax.ServiceAreaOutputType.Polygons
service_area.geometryAtOverlap = arcpy.nax.ServiceAreaOverlapGeometry.Split
# Load inputs
service_area.load(arcpy.nax.ServiceAreaInputDataType.Facilities, input_facilities)
# Solve the analysis
result = service_area.solve()
# Export the results to a feature class
if result.solveSucceeded:
result.export(arcpy.nax.ServiceAreaOutputDataType.Polygons, output_polygons)
else:
print("Solve failed")
print(result.solverMessages(arcpy.nax.MessageSeverity.All))