Find the service areas of several facilities from a feature service.
Use case
A service area is a region which can be accessed from a facility as limited by one or more factors, such as travel time, distance, or cost. When analyzing the service area of multiple facilities, this workflow can be used to identify gaps in service area coverage, or significant overlaps, helping to optimize the distribution of facilities. For example, a city's health service may identify areas of a city that can be served effectively from particular hospitals, and with this optimize distribution of staff and resources.
How to use the sample
Click 'find service area' to calculate and display the service area of each facility on the map. The polygons displayed around each facility represents the service area; in red is the area that is within 3 minutes away from the hospital by car. Light orange is the area that is within 5 minutes away from the hospital by car.
How it works
- Create a new
ServiceAreaTask
from a network service. - Create default
ServiceAreaParameters
from the service area task. - Set the parameters
ServiceAreaParameters.ReturnPolygons = true
to return polygons of all service areas. - Add facilities of the
ServiceAreaParameters
. For this, use a set ofQueryParameters
to select features from aServiceFeatureTable
:serviceAreaParameters.SetFacilities(_facilitiesTable, queryParameters)
. - Get the
ServiceAreaResult
by solving the service area task using the parameters. - For each facility, get any
ServiceAreaPolygons
that were returned,serviceAreaResult.GetResultPolygons(facilityIndex)
. - Display the service area polygons as
Graphics
in aGraphicsOverlay
on theMapView
.
About the data
This sample uses a street map of San Diego, in combination with a feature service with facilities (used here to represent hospitals). Additionally a street network is used on the server for calculating the service area.
Relevant API
- ServiceAreaParameters
- ServiceAreaPolygon
- ServiceAreaResult
- ServiceAreaTask
Tags
facilities, feature service, impedance, network analysis, service area, travel time
Sample Code
<UserControl
x:Class="ArcGISRuntime.UWP.Samples.FindServiceAreasForMultipleFacilities.FindServiceAreasForMultipleFacilities"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
<Grid>
<esriUI:MapView x:Name="MyMapView" />
<Border Style="{StaticResource BorderStyle}">
<StackPanel>
<Button x:Name="ServiceAreaButton"
IsEnabled="False"
HorizontalAlignment="Stretch"
Content="Find service area"
Click="FindServiceArea_Clicked" />
<ProgressBar x:Name="ProgressView"
IsIndeterminate="True"
MinHeight="10"
Visibility="Collapsed" />
</StackPanel>
</Border>
</Grid>
</UserControl>