This map indicates the distance from a given location in Richmond, Indiana, to the nearest grocery store. One goal of this visualization is to highlight areas that might classify as food deserts.
There are three different levels to which a user can interact with these data, and the prerequisites and approach for each is given below.
None
The exisiting data can be viewed online here: https://pjireland.github.io/distance_to_stores.html
Run the following command at the top level of the cloned repository:
python scripts/map_distance_to_stores.py
The resulting map will be placed within the results
directory under the
filename distance_to_stores.html
.
-
Python client library for Google Maps API Web Services. This can be installed via the command
pip install googlemaps
It is used to geocode (obtain the latitude and longitude) of grocery stores.
-
Sign up for a Google Maps API key.
- Note that that while Google Maps API is a paid service, the monthly free allowances are typically sufficient for geocoding the data, but be careful to not exceed your free allowance.
-
Download logos of any new grocery stores to the
data
folder. -
Add/modify grocery store data in the file
./data/grocery_stores.csv
.- The name, address, name of downloaded logo image, and desired width and height (in pixels) of the logo image should be added/modified.
-
Geocode the addresses
- Export your Google Maps API key to the environment variable
API_KEY
. On Linux and Mac machines, this can be done through the commandexport API_KEY=yourAPIkey
. - Run
python scripts/geocode_addresses.py
from the top level of the cloned repo to geocode each address in./data/grocery_stores.csv
.
- Export your Google Maps API key to the environment variable
-
Map the distance to the grocery stores
-
If desired, the variables near the top of the
./scripts/map_distance_to_stores.py
file can be modified to alter how the maps are drawn. -
The command
python scripts/map_distance_to_stores.py
should then be run in the top level of the cloned repository. -
The resulting map will be placed within the
results
directory under the filenamedistance_to_stores.html
.
-