Find Closest Facilities (Network Analyst)

License Level:BasicStandardAdvanced

Summary

Finds one or more facilities closest to an incident based on travel time, distance, or other cost and outputs the best route, chosen facility, and driving directions between the incident and the facility. For example, you can use this tool to find the closest hospital to an accident, the closest police cars to a crime scene, or the closest store to a customer's address.

When finding closest facilities, you can specify how many facilities to find and whether the direction of travel is toward or away from them. If your network dataset supports traffic, you can also specify the time of day to account for travel times for that time and date. For instance, you can use this tool to search for hospitals within a 15-minute drive time of the site of an accident at a given time of day. Any hospitals that take longer than 15 minutes to reach based on the traffic conditions will not be included in the results.

NoteNote:

The Find Closest Facilities and Make Closest Facility Layer tools are similar, but they are designed for different purposes. Use Find Closest Facilities if you are setting up a geoprocessing service; it simplifies the setup process. Otherwise, use Make Closest Facility Layer.

To create a closest facility geoprocessing service using Find Closest Facilities, you only need to set up one tool, and you can publish the tool directly as a service. In contrast, you need to create a model with the Make Closest Facility Layer tool, properly connect it to various other tools, and publish the model to create a closest-facility geoprocessing service. See Overview of the Network Analyst geoprocessing service examples to learn how to set up a closest facility service using tutorial data. One other option to consider is the ArcGIS Online Closest Facility service. It is a service that runs like a geoprocessing tool within ArcMap, can be accessed from other applications, and includes high quality road data for much of the world.

Usage

Syntax

FindClosestFacilities_na (Incidents, Facilities, Measurement_Units, Network_Dataset, Output_Geodatabase, Output_Routes_Name, Output_Directions_Name, Output_Closest_Facilities_Name, {Number_of_Facilities_to_Find}, {Default_Cutoff}, {Travel_Direction}, {Time_of_Day}, {Time_of_Day_Usage}, {Time_Zone_for_Time_of_Day}, {UTurn_Policy}, {Point_Barriers}, {Line_Barriers}, {Polygon_Barriers}, {Time_Attribute}, {Time_Attribute_Units}, {Distance_Attribute}, {Distance_Attribute_Units}, {Use_Hierarchy_in_Analysis}, {Restrictions}, {Attribute_Parameter_Values}, {Accumulate_Attributes}, {Maximum_Snap_Tolerance}, {Feature_Locator_WHERE_Clause}, {Route_Shape}, {Route_Line_Simplification_Tolerance}, {Populate_Directions}, {Directions_Language}, {Directions_Distance_Units}, {Directions_Style_Name}, {Maximum_Features_Affected_by_Point_Barriers}, {Maximum_Features_Affected_by_Line_Barriers}, {Maximum_Features_Affected_by_Polygon_Barriers}, {Maximum_Facilities}, {Maximum_Facilities_to_Find}, {Maximum_Incidents}, {Force_Hierarchy_Beyond_Distance}, {Save_Output_Network_Analysis_Layer})
ParameterExplanationData Type
Incidents

This tool determines which facilities are closest to incidents, and this parameter specifies those incidents. A minimum of one incident is necessary to solve an analysis.

When specifying the incidents, you can set properties for each one, such as its name or service time, by using attributes. The incidents can be specified with the following attributes:

OBJECTID—The system-managed ID field.

SHAPE—The geometry field indicating the geographic location of the incident.

Name—The name of the incident. The name is used in the driving directions. If the name is not specified, a unique name prefixed with Location is automatically generated in the output routes and directions.

ID—A unique identifier for the incident. The identifier is included in the output routes (as the IncidentID field) and can help join additional information from the output routes, such as the total travel time or total distance, to attributes from your incidents or vice versa. If the ID isn't specified, the service autogenerates a unique identifier for each incident.

AdditionalTime—The amount of time spent at the incident, which is added to the total time of the route. The units for this attribute value are specified by the Measurement Units parameter. The attribute value is included in the analysis only when the measurement units are time based. The default value is 0.

If you are finding the closest fire stations from fire incidents to estimate response times, the AdditionalTime attribute can store the amount of time it takes firefighters to hook up their equipment at the location of the incident before they can begin fighting the fire.

AdditionalDistance—The extra distance traveled at the incident, which is added to the total distance of the route. The units for this attribute value are specified by the Measurement Units parameter. The attribute value is included in the analysis only when the measurement units are distance based. The default value is 0.

Generally, the location of an incident, such as a home, isn't exactly on the streets; it is set back somewhat from the road. This attribute value can be used to model the distance between the actual incident location and its location on the street, if it is important to include that distance in the total travel distance.

CurbApproach—Specifies the direction a vehicle may arrive at and depart from the incident. The field value is specified as one of the following integers (use the numeric code, not the name in parentheses):

  • 0 (Either side of vehicle)—The vehicle can approach and depart the incident in either direction, so a U-turn is allowed at the incident. This setting can be chosen if it is possible and practical for your vehicle to turn around at the incident. This decision may depend on the width of the road and the amount of traffic or whether the incident has a parking lot where vehicles can pull in and turn around.
  • 1 ( Right side of vehicle)—When the vehicle approaches and departs the incident, the incident must be on the right side of the vehicle. A U-turn is prohibited. This is typically used for vehicles such as buses that must arrive with the bus stop on the right-hand side.
  • 2 (Left side of vehicle)—When the vehicle approaches and departs the incident, the curb must be on the left side of the vehicle. A U-turn is prohibited. This is typically used for vehicles such as buses that must arrive with the bus stop on the left-hand side.
  • 3 (No U-Turn)—When the vehicle approaches the incident, the curb can be on either side of the vehicle; however, the vehicle must depart without turning around.

The CurbApproach property is designed to work with both kinds of national driving standards: right-hand traffic (United States) and left-hand traffic (United Kingdom). First, consider an incident on the left side of a vehicle. It is always on the left side regardless of whether the vehicle travels on the left or right half of the road. What may change with national driving standards is your decision to approach an incident from one of two directions, that is, so it ends up on the right or left side of the vehicle. For example, if you want to arrive at an incident and not have a lane of traffic between the vehicle and the incident, you would choose Right side of vehicle (1) in the United States but Left side of vehicle (2) in the United Kingdom.

Feature Set
Facilities

This tool finds the nearest facilities to incidents, and this parameter specifies those facilities. A minimum of one facility is necessary to solve an analysis.

When specifying the facilities, you can set properties for each one, such as its name or service time, by using attributes. The facilities can be specified with the following attributes:

Name—The name of the facility. The name is used in the driving directions. If the name is not specified, a unique name prefixed with Location is automatically generated in the output routes and directions.

ID—A unique identifier for the facility. The identifier is included in the output routes (as the FacilityID field) and the output closest facilities as FacilityID fields. The FacilityID field can be used to join additional information from the output routes, such as the total travel time or total distance, to attributes from your facilities. If the ID isn't specified, the service autogenerates a unique identifier for each facility.

AdditionalTime—The amount of time spent at the facility, which is added to the total time of the route. The units for this attribute value are specified by the Measurement Units parameter. The attribute value is included in the analysis only when the measurement units are time based. The default value is 0.

If you are finding the closest fire stations to fire incidents, AdditionalTime can store the time it tends to takes a crew to don the appropriate protective equipment and exit the fire station.

AdditionalDistance—The extra distance traveled at the facility, which is added to the total distance of the route. The units for this attribute value are specified by the Measurement Units parameter. The attribute value is included in the analysis only when the measurement units are distance based. The default value is 0.

Generally the location of a facility, such as a fire station, isn't exactly on a street; it is set back somewhat from the road. AdditionalDistance can model the distance between the actual facility location and its location on the street, if it is important to include that distance in the total travel distance.

CurbApproach: Specifies the direction a vehicle may arrive at and depart from the facility. The field value is specified as one of the following integers (use the numeric code, not the name in parentheses):

  • 0 (Either side of vehicle)—The vehicle can approach and depart the facility in either direction, so a U-turn is allowed at the facility. This setting can be chosen if it is possible and practical for your vehicle to turn around at the facility. This decision may depend on the width of the road and the amount of traffic or whether the facility has a parking lot where vehicles can pull in and turn around.
  • 1 (Right side of vehicle)—When the vehicle approaches and departs the facility, the facility must be on the right side of the vehicle. A U-turn is prohibited. This is typically used for vehicles such as buses that must arrive with the bus stop on the right-hand side.
  • 2 (Left side of vehicle)—When the vehicle approaches and departs the facility, the curb must be on the left side of the vehicle. A U-turn is prohibited. This is typically used for vehicles such as buses that must arrive with the bus stop on the left-hand side.
  • 3 (No U-Turn)—When the vehicle approaches the facility, the curb can be on either side of the vehicle; however, the vehicle must depart without turning around.

The CurbApproach property was designed to work with both kinds of national driving standards: right-hand traffic (United States) and left-hand traffic (United Kingdom). First, consider a facility on the left side of a vehicle. It is always on the left side regardless of whether the vehicle travels on the left or right half of the road. What may change with national driving standards is your decision to approach a facility from one of two directions, that is, so it ends up on the right or left side of the vehicle. For example, if you want to arrive at a facility and not have a lane of traffic between the vehicle and the facility, you would choose Right side of vehicle (1) in the United States but Left side of vehicle (2) in the United Kingdom.

Feature Set
Measurement_Units

Specify the units that should be used to measure and report the total travel time or travel distance for the output routes. The tool finds the closest facility by measuring the travel time or the travel distance along streets.

The units you choose for this parameter determine whether the tool will measure driving distance or driving time to find what is closest. Choose a time unit to measure driving time. To measure driving distance, choose a distance unit. Your choice also determines in which units the tool will report total driving time or distance in the results. The choices are:

  • Meters
  • Kilometers
  • Feet
  • Yards
  • Miles
  • NauticalMiles
  • Seconds
  • Minutes
  • Hours
  • Days

The tool chooses whether to use the network cost attribute specified in the Time Attribute or Distance Attribute parameter depending on whether the chosen measurement units are time or distance based.

The tool performs the necessary unit conversion when the Measurement Units value differs from the units of the corresponding time or distance cost attribute.

String
Network_Dataset

The network dataset on which the analysis will be performed. Network datasets most often represent street networks but may represent other kinds of transportation networks as well. The network dataset needs at least one time-based and one distance-based cost attribute.

Network Dataset Layer
Output_Geodatabase

The output workspace. This workspace must already exist. The default output workspace is in_memory.

Workspace
Output_Routes_Name

The name of the output feature class containing routes or the lines that connect incidents to their closest facilities. This feature class also contains, as an attribute, the total cost of travel between the incidents and their nearest facilities.

Output from Find Closest Facilities describes the schema of this output feature class.

String
Output_Directions_Name

The name of the output feature class containing directions.

Output from Find Closest Facilities describes the schema of this output feature class.

String
Output_Closest_Facilities_Name

The name of the output feature class containing the closest facilities.

Output from Find Closest Facilities describes the schema of this output feature class.

String
Number_of_Facilities_to_Find
(Optional)

Specify the number of closest facilities to find per incident. This is useful in situations, such as a fire, where multiple fire engines may be required from different fire stations. You can specify, for example, to find the three nearest fire stations to a fire.

If you are setting up a service from this tool, and you want to limit resource usage such as processing time on your server, use the Maximum Facilities to Find parameter to limit the maximum number of facilities a user can enter in Number of Facilities to Find.

Long
Default_Cutoff
(Optional)

Specify the travel time or travel distance value at which to stop searching for facilities for a given incident. For instance, while finding the closest hospitals from the site of an accident, a cutoff value of 15 minutes would mean that the tool would search for the closest hospital within 15 minutes from the incident. If the closest hospital is 17 minutes away, no routes will be returned in the output routes. A cutoff value is especially useful when searching for multiple facilities.

The units for this parameter is specified by the Measurement Units parameter.

Double
Travel_Direction
(Optional)

Specify whether you want to search for the closest facility as measured from the incident to the facility or from the facility to the incident.

  • TRAVEL_FROMDirection of travel is from facilities to incidents.
  • TRAVEL_TODirection of travel is from incidents to facilities.

Using one of the parameter values can find different facilities as the travel time along some streets may vary based on the travel direction and one-way restrictions. For instance, a facility may be a 10-minute drive from the incident while traveling from the incident to the facility, but while traveling from the facility to the incident, it may be a 15-minute journey because of different travel time in that direction. If you are setting a value for Time of Day, traffic may also cause the Facility to Incident and Incident to Facility options to return different results.

Fire departments commonly use the Facility to Incident value for the parameter since they are concerned with the time it takes to travel from the fire station (facility) to the location of the emergency (incident). A retail store (facility) is more concerned with the time it takes the shoppers (incidents) to reach the store; therefore, stores commonly choose Incident to Facility.

String
Time_of_Day
(Optional)

Specifies the time and date at which the routes should begin or end. The value is used as the start time or end time for the route depending on the value for the Time of Day Usage parameter. If you specify the current date and time as the value for this parameter, the tool will use live traffic conditions to find the closest facilities and the total travel time will be based on traffic conditions.

If your network dataset contains live or historical traffic data, specifying a time of day results in more accurate estimation of travel time between the incident and facility because the travel times account for the traffic conditions that are applicable for that date and time.

The Time Zone for Time of Day parameter specifies whether this time and date refer to UTC or the time zone in which the facility or incident is located.

Irrespective of the Time Zone for Time of Day setting, if your facilities and incidents are in multiple time zones, the following rules are enforced by the tool:

  • All incidents must be in the same time zone when:

    • Specifying a start time and traveling from incident to facility.
    • Specifying an end time and traveling from facility to incident.

  • All facilities must be in the same time zone when:

    • Specifying a start time and traveling from facility to incident.
    • Specifying an end time and traveling from incident to facility.

Date
Time_of_Day_Usage
(Optional)

Indicates whether the Time of Day parameter value represents the arrival or departure time for the routes.

  • START_TIME When this option is chosen, the tool finds the best route considering the Time of Day parameter value as the departure time from the facility or incident.
  • END_TIME When this option is chosen, the tool considers the Time of Day parameter value as the arrival time at the facility or incident. This option is useful if you want to know what time to depart from a location so that you arrive at the destination at the time specified in Time of Day.
  • NOT_USEDWhen this option is chosen, the tool does not use a Time of Day when calculating the closest facilities. Live and historical traffic data will not be used.
String
Time_Zone_for_Time_of_Day
(Optional)

Specifies the time zone of the Time of Day parameter.

  • GEO_LOCALThe Time of Day parameter refers to the time zone in which the facilities or incidents are located.
    • If Time of Day Usage is set to START_TIME and Travel Direction is TRAVEL_FROM, this is the time zone of the facilities.
    • If Time of Day Usage is set to START_TIME and Travel Direction is TRAVEL_TO, this is the time zone of the incidents.
    • If Time of Day Usage is set to END_TIME and Travel Direction is TRAVEL_FROM, this is the time zone of the incidents.
    • If Time of Day Usage is set to END_TIME and Travel Direction is TRAVEL_TO, this is the time zone of the facilities.
  • UTCThe Time of Day parameter refers to Coordinated Universal Time (UTC). Choose this option if you want to find what's nearest for a specific time, such as now, but aren't certain in which time zone the facilities or incidents will be located.

Irrespective of the Time Zone for Time of Day setting, if your facilities and incidents are in multiple time zones, the following rules are enforced by the tool:

  • All incidents must be in the same time zone when:

    • Specifying a start time and traveling from incident to facility.
    • Specifying an end time and traveling from facility to incident.

  • All facilities must be in the same time zone when:

    • Specifying a start time and traveling from facility to incident.
    • Specifying an end time and traveling from incident to facility.

String
UTurn_Policy
(Optional)

The U-Turn policy at junctions. Allowing U-turns implies the solver can turn around at a junction and double back on the same street. Given that junctions represent street intersections and dead ends, different vehicles may be able to turn around at some junctions but not at others—it depends on whether the junction represents an intersection or dead end. To accommodate, the U-turn policy parameter is implicitly specified by how many edges connect to the junction, which is known as junction valency. The acceptable values for this parameter are listed below; each is followed by a description of its meaning in terms of junction valency.

  • ALLOW_UTURNSU-turns are permitted at junctions with any number of connected edges. This is the default value.
  • NO_UTURNSU-turns are prohibited at all junctions, regardless of junction valency. Note, however, that U-turns are still permitted at network locations even when this setting is chosen; however, you can set the individual network locations' CurbApproach property to prohibit U-turns there as well.
  • ALLOW_DEAD_ENDS_ONLYU-turns are prohibited at all junctions, except those that have only one adjacent edge (a dead end).
  • ALLOW_DEAD_ENDS_AND_INTERSECTIONS_ONLYU-turns are prohibited at junctions where exactly two adjacent edges meet but are permitted at intersections (junctions with three or more adjacent edges) and dead ends (junctions with exactly one adjacent edge). Oftentimes, networks have extraneous junctions in the middle of road segments. This option prevents vehicles from making U-turns at these locations.
TipTip:

If you need a more precisely defined U-turn policy, consider adding a global turn delay evaluator to a network cost attribute, or adjusting its settings if one exists, and pay particular attention to the configuration of reverse turns. Also, look at setting the CurbApproach property of your network locations.

String
Point_Barriers
(Optional)

Specifies point barriers, which are split into two types: restriction and added cost point barriers. They temporarily restrict traversal across or add impedance to points on the network. The point barriers are defined by a feature set, and the attribute values you specify for the point features determine whether they are restriction or added cost barriers. The fields in the attribute table are listed and described below.

ObjectID:

The system-managed ID field.

Shape:

The geometry field indicating the geographic location of the network analysis object.

Name:

The name of the barrier.

BarrierType:

Specifies whether the barrier restricts travel completely or adds cost when traveling through it. There are two options:

  • Restriction (0)—Prohibits traversing through the barrier. This is the default value.
  • Added Cost (2)—Traversing through the barrier increases the network cost by the amount specified in the Additional_Time and AdditionalDistance fields.

Use the value 0 for Restriction and 2 for Added Cost.

Additional_Time:

Indicates how much travel time is added when the barrier is traversed. This field is applicable only for added-cost barriers and only if the measurement units are time based. This field value must be greater than or equal to zero, and its units are the same as those specified in the Measurement Units parameter.

Additional_Distance:

Indicates how much distance is added when the barrier is traversed. This field is applicable only for added-cost barriers and only if the measurement units are distance based. The field value must be greater than or equal to zero, and its units are the same as those specified in the Measurement Units parameter.

Feature Set
Line_Barriers
(Optional)

Specifies line barriers, which temporarily restrict traversal across them. The line barriers are defined by a feature set. The fields in the attribute table are listed and described below.

ObjectID:

The system-managed ID field.

Shape:

The geometry field indicating the geographic location of the network analysis object.

Name:

The name of the barrier.

Feature Set
Polygon_Barriers
(Optional)

Specifies polygon barriers, which are split into two types: restriction and scaled cost polygon barriers. They temporarily restrict traversal or scale impedance on the parts of the network they cover. The polygon barriers are defined by a feature set, and the attribute values you specify for the polygon features determine whether they are restriction or scaled cost barriers. The fields in the attribute table are listed and described below.

ObjectID:

The system-managed ID field.

Shape:

The geometry field indicating the geographic location of the network analysis object.

Name:

The name of the barrier.

BarrierType:

Specifies whether the barrier restricts travel completely or scales the cost of traveling through it. There are two options:

  • Restriction (0)—Prohibits traversing through any part of the barrier. This is the default value.
  • Scaled Cost (1)—Scales the impedance of underlying edges by multiplying them by the value of the ScaledCostFactor property. If edges are partially covered by the barrier, the impedance is apportioned and multiplied.

Use the value 0 for Restriction and 1 for Scaled Cost.

ScaledTimeFactor

This is the factor by which the travel time of the streets intersected by the barrier is multiplied. This field is applicable only for scaled-cost barriers and only if the measurement units are time based. The field value must be greater than zero.

ScaledDistanceFactor

This is the factor by which the distance of the streets intersected by the barrier is multiplied. This attribute is applicable only for scaled-cost barriers and only if the measurement units are distance based. The attribute value must be greater than zero.

Feature Set
Time_Attribute
(Optional)

Defines the network cost attribute to use when the Measurement Units value is a time unit.

The tool performs the necessary time-unit conversion when the Measurement Units value differs from the units of the cost attribute defined here. In other words, the time units of the default cutoff and the network cost attribute don't need to be the same.

String
Time_Attribute_Units
(Optional)

The units of the time attribute. You can explicitly set the time attribute units, but it is recommended to pass nothing or "#" and let the solver determine the units.

String
Distance_Attribute
(Optional)

Defines the network cost attribute to use when the Measurement Units value is a distance unit.

The tool performs the necessary distance-unit conversion when the Measurement Units value differs from the units of the cost attribute defined here. In other words, the measurement units and the distance units of the network cost attribute don't need to be the same.

String
Distance_Attribute_Units
(Optional)

The units of the distance attribute. You can explicitly set the distance attribute units, but it is recommended to pass nothing or "#" and let the solver determine the units.

String
Use_Hierarchy_in_Analysis
(Optional)

Specify whether hierarchy should be used when finding the best route between the facility and the incident.

  • True Use hierarchy when finding routes. When hierarchy is used, the tool prefers higher-order streets (such as freeways) to lower-order streets (such as local roads), and can be used to simulate the driver preference of traveling on freeways instead of local roads even if that means a longer trip. This is especially true when finding routes to faraway facilities, because drivers on long-distance trips tend to prefer traveling on freeways where stops, intersections, and turns can be avoided. Using hierarchy is computationally faster, especially for long-distance routes, because the tool has to select the best route from a relatively smaller subset of streets.
  • False Do not use hierarchy when finding routes. If hierarchy is not used, the tool considers all the streets and doesn't prefer higher-order streets when finding the route. This is often used when finding short-distance routes within a city.

The parameter is not used if a hierarchy attribute is not defined on the network dataset used to perform the analysis. In such cases, use "#" as the parameter value.

You can use the Force_Hierarchy_Beyond_Distance parameter to force the solve to use hierarchy even if Use_Hierarchy_in_Analysis is set to false.

Boolean
Restrictions
[restriction,...]
(Optional)

Indicates which network restriction attributes are respected during solve time.

String
Attribute_Parameter_Values
(Optional)

Specifies the parameter values for network attributes that have parameters. The record set has two columns that work together to uniquely identify parameters and another column that specifies the parameter value.

The attribute parameter values record set has associated attributes. The fields in the attribute table are listed below and described.

ObjectID:

The system-managed ID field.

AttributeName:

The name of the network attribute whose attribute parameter is set by the table row.

ParameterName:

The name of the attribute parameter whose value is set by the table row. (Object type parameters cannot be updated using this tool.)

ParameterValue:

The value you want for the attribute parameter. If a value is not specified, the attribute parameter is set to null.

Record Set
Accumulate_Attributes
[attribute,...]
(Optional)

List of cost attributes to be accumulated during analysis. These accumulation attributes are purely for reference; the solver only uses the cost attribute specified by the Time Attribute or Distance Attribute parameter to calculate the route.

For each cost attribute that is accumulated, a Total_[attribute] property is added to the routes that are output by the solver.

String
Maximum_Snap_Tolerance
(Optional)

The maximum snap tolerance is the furthest distance that Network Analyst searches when locating or relocating a point onto the network. The search looks for suitable edges or junctions and snaps the point to the nearest one. If a suitable location isn't found within the maximum snap tolerance, the object is marked as unlocated.

Linear unit
Feature_Locator_WHERE_Clause
(Optional)

An SQL expression used to select a subset of source features that limits on which network elements facilities can be located. The syntax for this parameter consists of two parts: the first is the source feature class name (followed by a space) and the second is the SQL expression. To write an SQL expression for two or more source feature classes, separate them with a semicolon.

To ensure facilities are not located on limited-access highways, for example, write an SQL expression like the following to exclude those source features: "Streets" "FUNC_CLASS not in('1', '2')".

Note that barriers ignore the feature locator WHERE clause when loading.

String
Route_Shape
(Optional)

Specify the type of route features that are output by the tool. The parameter can be specified using one of the following values:

  • TRUE_LINES_WITH_MEASURES Return the exact shape of the resulting route based on the underlying streets. Additionally, construct measures so the shape may be used in linear referencing.
  • TRUE_LINES_WITHOUT_MEASURES Return the exact shape of the resulting route based on the underlying streets.
  • STRAIGHT_LINES Return a straight line between the incident and the facility.
  • NO_LINES Do not return any shapes for the routes. This value can be useful in cases where you are only interested in determining the total travel time or travel distance between the closest facility and the incident.

When the Route Shape parameter is set to True Shape, the generalization of the route shape can be further controlled using the appropriate values for the Route Line Simplification Tolerance parameters.

No matter which value you choose for the Route Shape parameter, the best route is always determined by minimizing the travel time or the travel distance, never using the straight-line distance between incidents and facilities. This means that only the route shapes are different, not the underlying streets that are searched when finding the route.

String
Route_Line_Simplification_Tolerance
(Optional)

Specify by how much you want to simplify the route geometry.

The tool ignores this parameter if the Route Shape parameter isn't set to TRUE_LINES_WITH_MEASURES or TRUE_LINES_WITHOUT_MEASURES.

Simplification maintains critical points on a route, such as turns at intersections, to define the essential shape of the route and removes other points. The simplification distance you specify is the maximum allowable offset that the simplified line can deviate from the original line. Simplifying a line reduces the number of vertices that are part of the route geometry. This improves the tool execution time.

Linear Unit
Populate_Directions
(Optional)

Specify whether the tool should generate driving directions for each route.

  • Checked (True) Indicates that the directions will be generated and configured based on the values for the Directions Language, Directions Style Name, and Directions Distance Units parameters.
  • Unchecked (False) Directions are not generated and the tool returns an empty Directions layer.
Boolean
Directions_Language
(Optional)

Specify the language that should be used when generating driving directions. This parameter is used only when the Populate Directions parameter is checked, or set to True.

The directions languages that are available depend on what ArcGIS language packs you have installed on your computer. The values are entered in two- or five-character language codes, for example, en for English or zh-CN for simplified Chinese.

If an unsupported language code is specified, the tool returns the directions using the default language, English.

String
Directions_Distance_Units
(Optional)

Specify the units for displaying travel distance in the driving directions. This parameter is used only when the Populate Directions parameter is checked, or set to True.

  • Miles
  • Kilometers
  • Meters
  • Feet
  • Yards
  • NauticalMiles

String
Directions_Style_Name
(Optional)

Specify the name of the formatting style for the directions. This parameter is used only when the Populate Directions parameter is checked, or set to True. The parameter can be specified using the following values:

  • NA Desktop Generates turn-by-turn directions suitable for printing.
  • NA Navigation Generates turn-by-turn directions designed for an in-vehicle navigation device.
  • NA CampusGenerates directions appropriate for pedestrian networks, including sidewalks and building interiors.
String
Maximum_Features_Affected_by_Point_Barriers
(Optional)

Limits how many features can be affected by point barriers.

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.

A null value indicates there is no limit.

Long
Maximum_Features_Affected_by_Line_Barriers
(Optional)

Limits how many features can be affected by line barriers.

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.

A null value indicates there is no limit.

Long
Maximum_Features_Affected_by_Polygon_Barriers
(Optional)

Limits how many features can be affected by polygon barriers.

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.

A null value indicates there is no limit.

Long
Maximum_Facilities
(Optional)

Limits how many facilities can be added to the closest facility analysis.

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.

A null value indicates there is no limit.

Long
Maximum_Facilities_to_Find
(Optional)

Limits how many facilities the user can ask the service to find.

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.

A null value indicates there is no limit.

Long
Maximum_Incidents
(Optional)

Limits how many incidents can be added to the closest facility analysis.

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.

A null value indicates there is no limit.

Long
Force_Hierarchy_Beyond_Distance
(Optional)

Specifies the distance after which the solver will force hierarchy even if hierarchy was not enabled when solving time-based service areas. The units of this parameter are the same as those shown in the Distance Attribute Units parameter.

Finding closest facilities that are far away while using the network's hierarchy tends to incur much less processing than finding the same closest facilities without using the hierarchy. This parameter helps you govern the amount of processing that occurs when solving.

A null value indicates that the hierarchy will never be enforced and the value of the Use Hierarchy in Analysis parameter will always be honored. If the input network dataset does not support hierarchy, specifying a value for this parameter will result in an error. A null value should be used in this case.

Double
Save_Output_Network_Analysis_Layer
(Optional)
  • NO_SAVE_OUTPUT_LAYERA network analysis layer isn't included in the output.
  • SAVE_OUTPUT_LAYERThe output includes a network analysis layer of the results.

In either case, feature classes with routes and directions are returned. However, a server administrator may want to choose to output a network analysis layer as well so the setup and results of the tool can be debugged using the Network Analyst controls in the ArcGIS for Desktop environment. This can make the debugging process much easier.

In ArcGIS for Desktop, the default output location for the network analysis layer is in the scratch folder. You can determine the location of the scratch folder by evaluating the value of arcpy.env.scratchFolder geoprocessing environment. The output network analysis layer is stored as an LYR file whose name begins with _ags_gpna and is followed by an alphanumeric GUID.

Boolean

Code Sample

FindClosestFacilities example 1

Execute the tool using the required parameters.

import arcpy
incidents = arcpy.FeatureSet()
incidents.load("Stores")
facilities = arcpy.FeatureSet()
facilities.load("Warehouses")
arcpy.na.FindClosestFacilities(incidents, facilities, "Minutes",
                                "Streets_ND", "in_memory", "Routes",
                                "Directions", "CLosestFacilities",
                                Number_of_Facilities_to_Find=1)
FindClosestFacilities example 2 (stand-alone Python script)

The following stand-alone Python script demonstrates how FindClosestFacilities can determine the nearest stores to a warehouse. You can modify the script to use other inputs to find the closest ambulance to an accident, work crew to a downed power line, and so on.

# Name: FindClosestFacilities_Workflow.py
# Description: For each store, find the closest warehouse. The output will show
#              the routes between stores and warehouses, driving directions,
#              and the subset of warehouses that were closest to stores.
# Requirements: Network Analyst Extension

#Import system modules
import arcpy
from arcpy import env

try:
    #Check out the Network Analyst extension license
    arcpy.CheckOutExtension("Network")

    #Set environment settings
    env.workspace = r'C:\arcgis\ArcTutor\Network Analyst\Tutorial\Paris.gdb'
    env.overwriteOutput = True

    #Set local variables
    inNetworkDataset = r'Transportation\ParisMultimodal_ND'
    inIncidents = r'Analysis\Stores'
    inFacilities = r'Analysis\Warehouses'
    outGeodatabase = r'C:\arcgis\ArcTutor\Network Analyst\Tutorial\Output.gdb'
    outRoutes = "Routes"
    outDirections = "Directions"
    outClosestFacilities = "ClosestFacilities"
    measurement_units = "Minutes"

    # Run FindClosestFacilities. Choose to find only the closest facility.
    arcpy.na.FindClosestFacilities(inIncidents, inFacilities, measurement_units,
                                    inNetworkDataset, outGeodatabase, outRoutes,
                                    outDirections, outClosestFacilities,
                                    Number_of_Facilities_to_Find=1)

    print "Script completed successfully"

except Exception as e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "An error occured on line %i" % tb.tb_lineno
    print str(e)

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Requires Network Analyst
ArcGIS for Desktop Standard: Requires Network Analyst
ArcGIS for Desktop Advanced: Requires Network Analyst
1/20/2015