Location of Interest Checker
Script to compare COVID locations of interest to Google location history.
The script produces a map plot (as shown below) as well
.csv file for further inspection of the data.
Figure: Output plot from checker script. Orange points are locations of interest, green points are personal locations at corresponding times. Blue lines show the 10 locations of interest you were closest to.
NOTE see health.govt.nz for the official list of locations of interest, and guidance on what to do if you have been at one.
I do not recommend the use of this script in lieu of manual checking of travel history against locations of interest. This script is largely untested, and further I am unsure as to whether Google location history records come with sufficient accuracy and frequency to reliably determine proximity to a location of interest.
Export Google location history
- Go to https://takeout.google.com/
- Under 'CREATE A NEW EXPORT`, deselect all, then select 'Location History', then 'Next Step'
- Follow instructions to download, then unzip exported data. This tool uses the file 'Location History.json'
To install this package/script into a virtualenv:
python -m venv venv
pip install git+https://github.com/tim-fan/location_of_interest_checker.git
Run the checker script. See the
-h flag for usage.
$ location_of_interest_checker -h
Locations of Interest Checker.
Check current New Zealand COVID locations of interest against exported Google location history.
Input arguments are the path to the exported location history json, and the file underwhich
to save the results of the check.
The output csv contains a list of all locations of interest, along with a column specifying how
far (in km) you were from that location at that time. If any distances are less
than, say 0.1km, you should probably get a test and self isolate!
for official list of locations of interest, and instructions on what to do if you have been at one.
location_of_interest_checker <location_history_file> <output_csv>
-h --help Show this screen.
For example, if your exported history file is saved as
location_of_interest_checker Location\ History.json /tmp/results.csv
On completion, the file
/tmp/results.csv can be opened in Excel or similar tools for inspection.
See the column
distance_to_location_km to see how close you were to the locations of interest.
- Think about packaging/distribution so this can easily be used by non-python users
- Provide instructions for windows setup - looks like this may be difficult with geopandas+pip: https://geopandas.readthedocs.io/en/latest/getting_started/install.html
- Improvements to the plot:
- More emphasis on high-proximity locations - currently it's easy to miss locations you were very close to, as the line will be very short - this is the oposite of how it should be!
- Better show the association between history points and interest points
- Better hover text
- Add a legend
- Color lines by distance
- Widgets for filtering by distance, time etc.
- Look into connecting directly to Google API to extract location history, rather than requiring manual export.
- Add a flag to match to closest location record (in time) in cases where no location history is present within the timebounds of a given location of interest
- alternatively, specify a maximum association time (e.g. match to records up to 1hr outside event interval)?
- Better configurability:
- support different timezones? Different source datasets?
- support different filtering start-times
- flags to enable/disable plotting and .csv export