Skip To Content

Determine service areas

In this topic

In network analysis, a service area is a polygon that represents all accessible parts of a network from a specified point and within a specified impedance. In other words, which area of the network can be accessed from a certain location without exceeding a given travel cost. This type of analysis allows you to visualize the proximity of features according to network travel in addition to standard spatial proximity. Service areas can be delineated for one or more input points (facilities) and can use one or several travel cost breaks.

Three service areas for a facility based on travel time

Examples of questions answered by service area analysis include:

  • Where are potential customers who can reach one of our stores in ten minutes or less?
  • Which areas of the city are not being served adequately by a fire station?
  • Where can I travel with the current charge on my electric car?

Some networks also use traffic information and can model travel impedance for different times of the day.

Define service area parameters

When defining service areas, you use ServiceAreaParameters to specify the required input facilities. You can also define preferences or constraints, like cutoff costs (breaks) that will define service areas for each facility. For instance, you can set up a service area task to define pizza delivery areas within 5-minute, 10-minute, and 15-minute drives of each store.

The following lists some of the available parameters you can specify for input to a service area task.

  • Facilities (required): points on the network that represent the center of the service area.
  • Impedance attribute: the name of an attribute in the network dataset that describes impedance to travel (travel time, for example).
  • Route barriers: points, lines, or polygons that act as barriers to travel on the network.
  • Default breaks: a set of impedance (cost) values that define the limit of each service area.
  • Travel direction: is travel away from or towards each facility.
  • Time of day: for networks that can model traffic at different times of the day.
  • Result geometry: how to handle overlapping, splitting, or trimming of result polygons.

The following example creates a new ServiceAreaParameters and sets properties to define inputs and preferences for a service area task.

// build the parameter values to use for the task
var findServiceAreaParams = new ServiceAreaParameters();
// ... the attribute that determines travel impedance along the route (travel time, energy consumed, etc.)
findServiceAreaParams.ImpedanceAttributeName = "TravelTime";
// ... the points that represent the facilities
findServiceAreaParams.SetFacilities(facilitiesWgs);
// ... what the output polygons should look like
findServiceAreaParams.OutputPolygons = OutputPolygons.Simplified;            
// ... the output spatial reference (match the current map view)
findServiceAreaParams.OutSpatialReference = MyMapView.SpatialReference;

The network service defines default values for many of these parameters. Instead of creating a new parameters object, you can get the default parameters from a ServiceAreaTask and then make changes to any of the values you would like to change.

// get the default parameters defined with the service (rather than creating it new)
var findServiceAreaParams = await findServiceArea.GetDefaultParametersAsync();

// make changes to some of the default parameters 
// ... the points that represent the facilities (will be the center of each service area)
findServiceAreaParams.SetFacilities(facilitiesWgs);
// ... travel cutoffs (breaks), each break will be represented as a service area polygon
findServiceAreaParams.DefaultBreaks = new double[] {0.5, 1.0, 1.5 };

Solving for service areas

You create a new ServiceAreaTask by pointing it to an online network service that can solve for service areas. Create the input parameters as shown in the preceding section, add a set of input points to represent facilities on the network, and (if you don't want to use the service default) define the cutoffs for the service areas. The result of solving the task will include basic information about each service area, such as the facility name, total area of the polygon, and the minimum and maximum travel cost.

The following example uses an online network service for San Diego to find service areas for 30, 60, and 90 second drive times from a facility.

// base url to an online network service
var onlineNetworkService = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/";
// append "ServiceArea" to the base url to use service area functionality 
var serviceAreaService = onlineNetworkService + "ServiceArea";

// create an Esri.ArcGISRuntime.Tasks.NetworkAnalyst.ServiceAreaTask based on the url
var findServiceArea = new ServiceAreaTask(new Uri(serviceAreaService));

// get the default parameters defined for the service
var findServiceAreaParams = await findServiceArea.GetDefaultParametersAsync(); 
// ... add the points that represent the facilities
findServiceAreaParams.SetFacilities(facilitiesWgs);
// ... define travel cutoffs (breaks), each will be represented as a service area polygon
findServiceAreaParams.DefaultBreaks = new double[] {0.5, 1.0, 1.5 };
// ... set the time of day for travel
findServiceAreaParams.TimeOfDay = DateTime.Now;
// ... define the output spatial reference (match the current map view)
findServiceAreaParams.OutSpatialReference = MyMapView.SpatialReference;

try
{
    // solve the service area problem with these parameters
    var findServiceAreaResult = await findServiceArea.SolveAsync(findServiceAreaParams);
    // process the results
    foreach (var area in findServiceAreaResult.Polygons)
    {
        // display service areas graphics
        serviceAreaGraphics.Graphics.Add(area as Graphic);
    }
}
catch (Exception ex)
{
    // handle exceptions here
}