Andrew Jones

Home   Blog   Projects   Tutorials   Map Gallery

Your Location History: Using Google Location History in ArcGIS Pro


It should come as no surprise that location history is recorded by Google. This is done in order to provide personalized services, such as maps, traffic updates, and location-based recommendations, using data from devices linked to a Google account. However, this data belongs to you, and with a bit of effort, it can be exported and used. To begin, "Google Takeout" should be searched for in a browser. The results should resemble Figure 1 below.


Google Takeout Web Search
Figure 1. Searching for Google Takeout on the Web

Next, a large list of different data options will appear, from which selections can be checked for export (Figure 2). For this tutorial, "Location History" should be located by scrolling down the list.


Google Takeout Data Options
Figure 2. Data Options from Google Takeout

Ensure that "Location History" is checked. It is displayed below in Figure 3.


Google Takeout Location History
Figure 3. Checking Off Location History in Google Takeout

A few different options are available for how the data can be exported. A download link can be sent to your Gmail, or the Takeout data can be placed in cloud storage. Additionally, the download can be split into two-month intervals (resulting in six files) or provided as a single file for the entire year. File types include .zip or .tgz, and several file size options are available, ranging from 1 to 50 gigabytes. If the file size is smaller than the total size of the location history, multiple files will be sent to match the size of the location history. The available options are displayed in Figure 4 below.


Google Takeout Settings
Figure 4. Export Options for Google Takeout

The Google Takeout data should be downloaded from either the email link or cloud storage and unzipped. It is likely to be quite large—mine, for example, was around 651 megabytes in size. Unfortunately, the data is in a proprietary JSON format. To use it in ArcGIS Pro, adjustments will need to be made to standardize the data.


Given the large size of the Google Takeout data, attempting to manually edit it would be inefficient. At this point, a Python script should be considered to transform the data into a standardized JSON format or another suitable format. Fortunately, several such scripts are available on GitHub. The most accessible script is location-history-json-convertor by Gerwin Sturm (Figure 5). The location-history-json-converter.py script should be downloaded.


Location History Convertor
Figure 5. Location History Convertor Python Script

To keep things organized, it is best for the unzipped Google Takeout data and the Python script to be moved into the same folder (Figure 6).


Folder for Data
Figure 6. Storing the Google Takeout Data and Python Script in the Same Folder

Now, the requisites for running the Python script should be considered. Python 3.2 or higher is required, so it must be ensured that it is installed and up to date. Additionally, a few Python libraries will be needed. These are listed in the "requirements.txt" file on the Python script's webpage, but they include "Ijson," "Shapely," and "python-dateutil." These libraries can be installed using PIP in the Windows Command Prompt (Figure 7). To install them, simply type "pip install ___," replacing the blank with each package name (Ijson, Shapely, python-dateutil). The Command Prompt should be left open, as it will be used in the next step.


Using PIP
Figure 7. Using PIP to Install Required Python Packages

With the packages installed, the Python script can now be run. This will also be done in the Command Prompt. In Command Prompt, the folder containing the Google Takeout data and Python script should be navigated to. This can be done by typing "cd (system path to your folder)" (Figure 8).


CMD cd
Figure 8. Changing your Directory on Command Prompt

For the purposes of this tutorial, .kml will be used as the output file format, which will later be converted into a shapefile. Other available options include .csv, .json, .js, and .gpx. To run the script, the following parameters should be entered in the Command Prompt:


python location_history_json_converter.py LocationHistory.json MyLocations.kml

The script should then be run.


Running Python script
Figure 9. Inputting the Parameters for and Running the Python Script

The .kml file should be generated successfully. It should then be added to ArcGIS Pro (or another GIS software) to visually depict the data. Converting it to a shapefile will make it easier to edit. In ArcGIS Pro, the KML to Layer tool should be run (a similar tool is available in QGIS). Note that if the location history file is large, running the tool may take a significant amount of time. If ArcGIS Pro seems to freeze or take too long, it may be prudent to reconsider the scope of the location data needed and request a more limited Google Takeout dataset. Figure 10 below shows the shapefile of my location history.


Location History
Figure 10. My Location History

At this point, the location history can be used in any way desired. Personally, I chose to use my Google data to create an ArcGIS JavaScript API web map that would display some of my travel photos. To do this, around 120 points that corresponded with photo locations were selected. The photos were uploaded to Imgur, and a unique field for the image links was created and populated with the Imgur URLs. The location data shapefile was then converted into a GeoJSON file (using the Features To JSON tool) to ensure it would work seamlessly for online display.


Below is an older version of the interactive web map of my travel photos from the front page of this website. The code for it can be found here.




List of Figures and Tables


Figure 1. Searching for Google Takeout on the Web

Figure 2. Data Options from Google Takeout

Figure 3. Checking Off Location History in Google Takeout

Figure 4. Export Options for Google Takeout

Figure 5. Location History Convertor Python Script

Figure 6. Storing the Google Takeout Data and Python Script in the Same Folder

Figure 7. Using PIP to Install Required Python Packages

Figure 8. Changing your Directory on Command Prompt

Figure 9. Inputting the Parameters for and Running the Python Script

Figure 10. My Location History

References


Scarygami. (n.d.). GitHub - Scarygami/location-history-json-converter: Convert the Location History JSON File from Google Takeout into a useable format. GitHub. https://github.com/Scarygami/location-history-json-converter

Sign in - Google Accounts. (n.d.). https://takeout.google.com/settings/takeout