Exercise 5: Calculating service areas and creating an OD cost matrix
In this exercise, you will create a series of polygons that represent the distance that can be reached from a facility within a specified amount of time. These polygons are known as service area polygons. You will calculate 3-, 5-, and 10-minute service areas for six warehouses in Paris.
You will also find how many stores are within each of these service areas. You will identify one warehouse that should be relocated to better service the stores. Additionally, you will create an origin–destination cost matrix for delivery of goods from the warehouses to all stores within a 10-minute drive time. Such a matrix is used as an input for logistics, delivery, and routing analyses.
The data for this exercise and the other exercises in the Network Analyst tutorial is available on ArcGIS.com. After downloading the data, you can extract it wherever you like. It may be helpful, however, to extract it to C:\arcgis\ArcTutor since the tutorial refers to this path as the default location for the data.
Preparing your display
- If you have Exercise05.mxd open in ArcMap, skip to step 6.
- Start ArcMap by clicking Start > All Programs > ArcGIS > ArcMap 10.2.2.
- On the ArcMap - Getting Started dialog box, click Existing Maps > Browse for more.
-
Browse to C:\ArcGIS\ArcTutor\Network Analyst\Tutorial.
This is the default installation location for the tutorial data.
-
Double-click Exercise05.mxd.
The map document opens in ArcMap.
-
Enable the ArcGIS Network Analyst extension.
-
Click Customize > Extensions.
The Extensions dialog box opens.
- Check Network Analyst.
- Click Close.
-
Click Customize > Extensions.
-
Click Customize > Toolbars > Network Analyst.
The Network Analyst toolbar is added to ArcMap.
-
On the Network Analyst toolbar, click the Network Analyst window button .
The dockable Network Analyst window opens.
If the Network Analyst toolbar is not displayed, you need to add it.
If the Network Analyst window is not displayed, you need to add it.
You can dock or undock the Network Analyst window.
Creating the service area analysis layer
-
Click Network Analyst on the Network Analyst toolbar and click New Service Area.
The service area analysis layer is added to the Network Analyst window. The network analysis classes (Facilities, Polygons, Lines, Point Barriers, Line Barriers, and Polygon Barriers) are empty.
The analysis layer is also added to the Table Of Contents window.
Adding facilities
Next, you will add warehouses as facilities for which the service area polygons will be generated.
-
Press CTRL while you drag the Warehouses feature layer from the Table of Contents window and drop it in the Facilities class in the Network Analyst window.
The six warehouses are loaded as facilities and displayed in the map.
-
In the Network Analyst window, click the plus (+) sign next to Facilities (6) to see a list of the facilities.
Setting up the parameters for the analysis
Next, you will specify that your service area will be calculated based on drive time (using minutes). Three service area polygons will be calculated for each facility, one at 3 minutes, one at 5 minutes, and another at 10 minutes. You will specify that the direction of travel will be from the facility—not toward the facility, that no U-turns are allowed, and that one-way restrictions must be followed.
-
Click the Analysis Layer Properties button on the Network Analyst window.
The Layer Properties dialog box opens.
- Click the Analysis Settings tab.
- Make sure that Impedance is set to use DriveTime (Minutes).
- Type 3 5 10 in the Default Breaks text box.
- Under Direction, click Away From Facility.
- Choose Not Allowed from the U-Turns at Junctions drop-down list.
- Leave Ignore Invalid Locations checked.
- Check Oneway in the Restrictions list.
- Click the Polygon Generation tab.
- Make sure that Generate Polygons is checked.
-
For Polygon Type, click Generalized.
Detailed polygons are more accurate but need more time to be generated.
-
Uncheck the Trim Polygon option.
This is a postprocess that trims the outside polygon to remove spikes but takes a little longer to run.
-
Click Overlapping for the Multiple Facilities Options.
This results in individual polygons for each facility. A polygon from one facility might overlap with a polygon from another, nearby facility.
-
Click Rings for the Overlap type.
This excludes areas of smaller breaks from the polygons of a bigger break.
- Click Apply to save the settings.
- Click the Line Generation tab.
-
Leave Generate Lines unchecked.
Although you won't generate lines from the edges that are traversed in this exercise, you could by checking this option.
It is possible to output lines, polygons, or both.
- Click OK.
Run the process to compute the service area
-
Click the Solve button on the Network Analyst toolbar.
The service area polygons appear on the map and on the Network Analyst window.
- In the Table Of Contents window, right-click the Polygons sublayer and choose Properties.
- Click the Symbology tab.
-
Click the Symbol field name and choose Flip Symbols. (Make sure you click—not right-click—Symbol; otherwise, you won't see a context menu.)
-
Click OK.
The outer and inner service area breaks switch colors, making it clearer what areas the 10-minute breaks cover.
Identifying stores that are outside all service areas
-
In the Table Of Contents window, click and drag Stores to the top of the Layers list to improve visibility.
-
Click Selection > Select By Location.
-
Create the selection query on the Select By Location dialog box to select features from stores that are completely within polygons, as shown below.
-
Click OK.
The stores that are within the polygons are selected; however, you want to select the stores that are outside the service area polygons.
-
In the Table Of Contents window, right-click Stores and click Selection > Switch Selection.
The selection now shows the distribution of stores not contained in any service area polygons. Use this selection to identify the area in which you will relocate a warehouse. The best area appears to be in the center of the map.
- On the Tools toolbar, click the Clear Selected Features button .
Relocating the least accessible warehouse
Look at the service area polygons of Warehouse #2. There are not any stores within the 3-, 5-, or 10-minute service areas around Warehouse #2; hence, you will relocate that warehouse to better service the stores.
-
On the Network Analyst window, select Warehouse #2 under Facilities (6).
- Click the Select/Move Network Location Tool on the Network Analyst toolbar.
-
On the map display, drag Warehouse #2 to the center of the map as shown below.
Run the process to compute the service area
-
Click the Solve button on the Network Analyst toolbar.
The service area polygons appear on the map and the Network Analyst window.
Identifying the service area polygon that each store is within
-
In the Table Of Contents window, right-click Stores and click Joins and Relates > Join.
The Join Data dialog box opens.
-
Choose Join data from another layer based on spatial location.
-
Choose Polygons as the layer to join to this layer.
-
Click the it falls inside button.
This adds the attributes of the polygon to all points that fall inside the polygon.
-
Specify an output shapefile or feature class to save the join results to and name it StoresWithPoly.
-
Click OK.
ArcGIS performs the join and adds the new layer to the map document.
-
In the Table Of Contents window, right-click the new StoresWithPoly feature layer and choose Open Attribute Table.
Each row in the table displays the name of the store and polygon it falls under. You can use this table to generate other useful categories, such as the number of stores within 0-to 3-minute service areas.
- Close the attribute table.
-
In the Network Analyst window, right-click Facilities (6) and choose Export Data.
The Export Data dialog box opens.
- In the Export drop-down list, choose All features.
-
Choose an output location and type (shapefile or feature class).
You might choose to store a feature class in the Paris geodatabase: C:\arcgis\ArcTutor\Network Analyst\Tutorial\Paris.gdb\New_Warehouses
-
Click OK.
A message appears asking if you want to add the exported data to the map.
-
Click No.
You won't need the data for the rest of this exercise.
Creating an OD cost matrix analysis layer
Optionally, you can create an origin–destination cost matrix for deliveries from the new warehouses to each store. The results of this matrix can be used to identify stores that will be serviced by each warehouse within a 10-minute drive time. Also, you can find the total drive time from each warehouse to its stores.
- In the Table Of Contents window, uncheck the Service Area analysis layer and the StoresWithPoly feature layer to improve readability of the map.
-
Click Network Analyst on the Network Analyst toolbar and click New OD Cost Matrix.
The OD cost matrix analysis layer is added to the Network Analyst window. The network analysis classes (Origins, Destinations, Lines, Point Barriers, Line Barriers, and Polygon Barriers) are empty.
The analysis layer is also added to the Table Of Contents window.
Adding origins
You can use the facilities from the service area analysis (in the previous sections) as origins. If you have not completed the section on service areas, you can use the Warehouses feature layer instead.
-
In the Network Analyst window, right-click Origins (0) and choose Load Locations.
The Load Locations dialog box opens.
- Click ServiceArea/Facilities in the Load From drop-down list. (If you did not complete the previous sections on service area analysis, you can choose Warehouses instead.)
- Uncheck Only load selected rows.
-
Under Location Position, click Use Network Location Fields. (If you are loading Warehouses, click Use Geometry.)
Using network location fields allows ArcGIS to use the already-located position of service area facilities to locate them again as origins. This is much faster than using a spatial search to locate them again.
-
Click OK.
The six new origins are displayed on the map and listed in the Network Analyst window under Origins.
Adding destinations
- In the Network Analyst window, right-click Destinations (0) and choose Load Locations.
- Choose Stores in the Load From drop-down list.
-
Under Location Analysis Properties, for the property name, choose NOM from the Field drop-down list.
Since the French field name NOM is not configured in the NASolverConfiguration.xml file, ArcGIS is unable to map the field name automatically.
-
Click OK.
The Network Analyst window now lists 21 destinations.
These destinations are also displayed on the map.
Setting up the parameters for the analysis
Next, you will specify that your OD cost matrix will be calculated based on drive time. You will set a default cutoff value of 10 minutes and ensure that all destinations are found within the specified cutoff. Additionally, you will specify that U-turns are allowed everywhere and the output Shape type should be a straight line. Since all these trips are on roads, one-way restrictions must be followed. All invalid locations (locations not found) will be ignored.
-
Click the Analysis Layer Properties button on the Network Analyst window.
- Click the Analysis Settings tab.
- Make sure that the Impedance drop-down list is set to DriveTime (Minutes).
- Leave Use Start Time unchecked.
-
Type 10 in the Default Cutoff Value text box.
This will create origin–destination paths from each warehouse to all stores that can be reached within 10 minutes. Minutes are the units since the impedance attribute is in minutes.
- Make sure that Destinations To Find is set to <All>.
- Click the U-Turns at Junctions drop-down arrow and choose Allowed.
- Make sure that Output Shape Type is set to Straight Line.
- Make sure that Ignore Invalid Locations is checked.
-
Check Oneway in the Restrictions list.
-
Click OK.
The parameter settings are saved.
Run the process to create the OD cost matrix
-
Click the Solve button on the Network Analyst toolbar.
The OD lines appear on the map. There are 24 lines in this example. This number may be different for you, depending on where you relocated Warehouse #2.
- If the Service Area layer is not displayed, turn it on to show the OD Cost Matrix layer on top of the service areas of the warehouses.
Allocating stores to warehouses
Based on the OD cost matrix, you can now identify the stores that would be served by each warehouse.
-
In the Network Analyst window, right-click Lines (24) and choose Open Attribute Table.
The Lines table opens.
- If you don't plan to work on any other exercise, exit ArcMap. Click No to discard any changes.
-
If you plan to work on another exercise, follow the substeps below.
-
Click File > New.
The New Document dialog box opens.
- Click OK.
- Click No when prompted to save changes.
-
Click File > New.
The Lines table represents the origin–destination cost matrix from each warehouse to the stores within a 10-minute drive time. The OriginID column contains IDs of warehouses. The DestinationID column contains IDs of stores. The DestinationRank is a rank assigned to each destination that is served by a store based on the total drive time. For example, in the table below, for Warehouse #1, DestinationID 2 has a rank of 1, and DestinationID 3 has a rank of 2. This is because it takes less time to go from Warehouse #1 to DestinationID 2. (This may be different for you, as your analysis results are dependent on the source feature class of the origins and destinations.)
The OD cost matrix displays the stores serviced by each warehouse along with the total drive time for each route. Some stores are within a 10-minute accessibility zone of more than one warehouse and can be served by any one of them. The OD cost matrix can also be used as an input in logistics routing models that use origin–destination matrices to allocate goods and services.