Geoprocessing with Python: Location-Allocation of Dunkin Donuts Stores in San Francisco

Introduction

This project was designed to see the viability of using python with ArcGIS Desktop to automate network analysis. The challenge I set for myself was to analyze where to locate new Dunkin Donuts stores in San Francisco, so that large consumer areas would be within 5 minutes travel time.  Since automating network analysis is a difficult process, one of my goals was to see if using python could simplify the process for others attempting network analysis.

Methodology

I started the project by attempting to make a network layer for Salt Lake City.  With only partially completed data layers I was unable to successfully create a network layer with associated distance and time information.  Without a network layer the python code could not be tested.  After failing to create a network layer for Salt Lake City, I changed my study area to San Francisco for which I was able to find a functioning network layer.  At this time I began testing and editing the python code.  The main coding errors I encountered were due to the order the layers were called by the script and improper variable inputs (Figure 1).  The python code had to follow the same structure as the ArcGIS Desktop tool it is referencing.  Each of the network layers had to be called in the order the location-allocation tool was expecting or the analysis would not run properly.

Figure 1. Location-allocation variable list

Conclusion

While using Python made the process fast, it was not necessarily easy because of the limited interface between Python and ArcGIS Desktop.  The location-allocation tool already had specific python coding that needed to be followed.  The initial run was always the slowest, but any iteration after that was much faster.  I performed a number of tests to ensure consistent results.  Although the final product was not fully automated because of the complexity of the location-allocation tool it was possible to run the tool with one line of code after the initial run (Figure 2).  The final conclusion for this project is that the python script is extremely complex to run with python.  The tool interface in ArcGIS Pro is much smoother and simplifies the process compared to ArcGIS Desktop.

Figure 2. Location-allocation one line code snippets

Results

Below is the output of the location-allocation code for one store (Figure 3). In order to test the accuracy multiple runs were conducted to ensure a consistent outcome. After the initial testing, code was developed to run location-allocation for multiple candidate stores (Figure 4).

The final results of the analysis are depicted as graphs. When the number of new stores increases the less demand points per store (Figure 5). The upside to more stores is that the travel distance to each store is lower (Figure 6). The average distance does not change that much with an increase in number of stores. To save money it would be more cost effective to build fewer stores that cover more demand.

Skills

  • Basic Programming or Scripting
  • GIS Analysis
  • Communication

Design a site like this with WordPress.com
Get started