Supermarket Locations (GIS course)
Python scripts I wrote for the final project in my Intro to Mapping and GIS course. They gather supermarket addresses across New Jersey and turn them into map coordinates with the ArcGIS geocoding service.
- Python
- BeautifulSoup
- ArcGIS
- CSV
Overview
The final project in my Intro to Mapping and Geographic Information Systems course was a map made in ArcGIS. I wanted a map of supermarkets in New Jersey, and I couldn’t find that data anywhere. Writing code to collect it wasn’t part of the assignment, but I did it anyway, because I needed the data.
The map itself was made in ArcGIS, and isn’t in the repository. What is there is the part that got the data.
What the scripts do
There is one script per chain, covering stores such as ShopRite, Stop & Shop, Wegmans and Whole Foods. Each one gets a list of store addresses and writes a CSV file of coordinates and addresses, which I then loaded into ArcGIS as point data. The repository also has the resulting data as CSV and Excel files, for about 360 locations.
Getting the addresses took a different approach for each chain:
- For some chains, the script reads addresses out of a web page with BeautifulSoup.
- ShopRite’s site blocks scripts, so I saved the page by hand and had the script read that file instead.
- Wegmans had only nine stores in New Jersey, so those addresses are typed straight into its script.
Every script then does the same last step: it asks the ArcGIS geocoding service for the latitude and longitude of each address, using the geopy library, and pauses briefly between requests. A small Store class holds an address and its coordinates, so all of the scripts share it. My ArcGIS login details are kept in a .env file instead of in the code.
Where it stands
The README is upfront that the scripts aren’t maintained. Store websites change, so they probably don’t run any more. They did what I needed at the time, and the data they produced is still in the repository.