Skip to main content

A package to pull, plot, and analyze coordinates from photos.

Project description

GeoPhotos is a package to pull, analyze, and plot coordinates from various sources.

latest release

What is GeoPhotos?

GeoPhotos is a Python library designed to make it easy to pull coordinates from various sources, analyze them in order to obtain useful information, and plot them on a map.

Main features

An overview of some of the major features of GeoPhotos are as follows:

  • Extract metadata (timestamp, coordinates, etc.) from one or more files, and write to a csv file if desired
  • Pull coordinates from Google Takeout location history
  • Plot coordinate data on a fully customizable heatmap, including markers, tooltips, layer control, and more
  • Analyze coordinate data to determine unique countries, most common countries, and more
  • Highlight certain countries on the heatmap easily and painlessly
  • Save the map to an html file for reference or for use with web development frameworks such as flask
  • Open the html file directly from the code for debugging

How to get it

Dependencies

Required dependencies

Currently, the following packages are required:

Some packages that are currently required may be made optional in the future, such as the gdal/osgeo package.

Optional Dependencies

The geopandas package has been made optional due to how difficult it is to install properly. It is required to perform geographical data analysis.

Installation

Assuming you've already got the dependencies covered, you can use pip to install this package:

pip install geophotos

However, you will most likely run into problems doing it this way. Unfortunately, I have tried and failed to overcome these obstacles myself. My recommendation is to install geopandas using Anaconda/conda (you might have to install gdal as well), and then pip install it into your current environment:

conda install geopandas
conda install gdal
pip install geophotos

This should handle all of the dependencies for you, although you still might run into some issues (I sure did!).

Updating

To update geophotos to the latest version, simply use the command:

pip install --upgrade geophotos

Example usage

Heatmap from photo locations

One of the main reasons I made this package was to pull GPS information from the pictures in my iCloud library, then plot them on a map. Skipping the pulling of the coordinates for simplicity's sake, the following code does the following:

  1. Read latitudes and longitudes from a csv file
  2. Generate a heatmap using this coordinate data
  3. Add a marker that marks my hometown
  4. Analyze the data and determine which countries I've visited
  5. Highlight only the countries I've been to on a separate layer
  6. Save the map as an html file and open it in a web browser

The html file is completely interactive, and I hope to eventually use it on my personal website.

import geophotos as gp

# Read coordinate data from csv
data = gp.coordinates_from_csv(r'coordinates.csv', 2, 3)
# Initialize the Map object
nys_center = [42.965000, -76.016667]
heatmap = gp.Map(location=nys_center, zoom_start=7)
# Feed the Heatmap object the coordinates
heatmap.coordinates = data
# Create the heatmap
heatmap.create_heatmap(max_zoom=10, min_opacity=0.05, radius=13, blur=25,
                       name='Photo Heatmap')
# Add a marker to the heatmap
hamburg_ny = [42.715746, -78.829416]
heatmap.add_marker(location=hamburg_ny,
                   tooltip='<strong>Hamburg, NY</strong><br>Hometown')
# Analyze the data to determine which countries are unique
analyzer = gp.Analyzer(data)
unique_countries = analyzer.unique_countries(),
# Use the data to determine which countries to highlight
border_layer = gp.CountryLayer(unique_countries, name='Countries Visited')
border_layer.add_to(heatmap)
# Add layer control functionality to the map
heatmap.add_layer_control()
# Save the heatmap and open it in a browser
heatmap.save_html('sample.html', open_html=True)

Sample geophotos photo analysis output map

Heatmap from Google Takeout location history

Another thing I wanted to do when starting this project was be able to analyze my Google Takeout location data. While not an overly complicated thing to do without GeoPhotos, it does make this process very simple.

For example, the following code extracts coordinate information from the Google Takeout location history JSON file and plots them on a heatmap. It's really interesting to see where you've been the most.

import geophotos as gp

# Read coordinate data from the location history file
data = gp.coordinates_from_google_takeout_json(r'locationhistory.json')
# Initialize the Map object
nys_center = [42.965000, -76.016667]
heatmap = gp.Map(location=nys_center, zoom_start=7)
# Feed the Heatmap object the coordinates
heatmap.coordinates = data
# Create the heatmap
heatmap.create_heatmap(max_zoom=14, min_opacity=0.05, radius=13, blur=25)
# Save the heatmap and open it in a browser
heatmap.save_html(r'locationhistory.html', open_html=True)

Sample geophotos location history analysis output map


Authors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geophotos-0.50.1.tar.gz (7.0 MB view details)

Uploaded Source

File details

Details for the file geophotos-0.50.1.tar.gz.

File metadata

  • Download URL: geophotos-0.50.1.tar.gz
  • Upload date:
  • Size: 7.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

File hashes

Hashes for geophotos-0.50.1.tar.gz
Algorithm Hash digest
SHA256 a4137b2a6c6f6f5fe0b093efc9b82e2709425bc8071f9718b27c2ced54cbabec
MD5 4b2b85a5d2bc1bb0509551af277594be
BLAKE2b-256 50dd30fcb497cc7006322472bf4e8be76af1348b71cece4663a9a7f42a50a837

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page