Thank you to makepath for their collaboration on this blog.
At makepath, we specialize in turning data into insights using open source spatial analysis tools. As the United States continues to adjusts to the COVID19 pandemic, we asked the question:
"It’s 12:00pm and I need to go to a store RIGHT NOW, where should I shop to effectively social distance?"
SafeGraph's Places Patterns dataset gives us the fine-grain foot traffic data we need to explore our question. We can easily filter foot traffic based on retail categories, and visualize foot traffic to reveal structure in foot traffic patterns based on our stores of interest.
We detail the analysis below and are sure you can use similar techniques to explore your own analysis questions. We opted to use a raster-based approach, which demonstrates aggregation of data into spatially-aligned grids using Datashader, Xarray-Spatial, and Geopandas.
Like all spatial analyses, we start by defining our study area. Our study area focuses on Austin, Texas and includes a willingness to travel radius of 5km. We use a geodesic radius which is why our area is an elliptical as opposed to purely circular.
We also added a street layer, to provide additional context to our study area. We obtained streets from the City of Austin’s Open Data Portal.
A common data analysis pattern is split, apply, combine. We can use this paradigm to frame the steps needed to answer our social-distancing question.
Split is the action of dividing data into meaningful groups. For our question, we split up SafeGraph Places Patterns data into groups based on retail category. SafeGraph provides dozens of retail categories, and hundreds of retail subcategories.
Our retail categories of interest included:
During our Apply step, we run each group of stores through a series of transforms. At this stage, each retail group is considered independently. SafeGraph’s data includes everything we need to know about our retail stores including popularity by time, popularity by day of week, square footage, and lat/lng location.
For our analysis, the following transforms were applied to each retail category:
With our split and apply stages complete, we can now combine our transformed location layers into a single for each retail group. This step is easy because we’ve already spatially-aligned each of our layers using Datashader and Xarray-Spatial. We can mosaic our output images together to look at various retail sectors and compare them visually.
Ok, so where should we shop? Below is a table of the best retail location we identified based on our time of day (12pm noon) and the retail segment of interest:
The most powerful tools for understanding our world exist within the open source software community. The best data for understanding foot traffic data comes from SafeGraph. Combined, analysts can uncover critical insights to help decision-makers achieve the best outcomes possible for their organizations.
We challenge you to use similar spatial analysis techniques in answering your own questions. By leveraging SafeGraph data with tools like Datashader and Xarray-Spatial, you are limited only by the insightfulness of your questions.
To see the technical aspects of this blog put into action via code, check out the accompanying notebook.
Brendan Collins is Founder and Principal of makepath, a spatial data science firm in Austin, Texas. The team at makepath is passionate about open source spatial analysis tools and using open source GIS libraries to solve tough data problems such as identifying pharmacy deserts.
That's it – that's all we do. We want to understand the physical world and power innovation through open access to geospatial data. We believe data should be an open platform, not a trade secret. Information should not be hoarded so that only a few can innovate.