Package: geophotos
GeoPhotosis a package to pull, analyze, and plot coordinates from various
sources.What isGeoPhotos?GeoPhotosis 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 featuresAn overview of some of the major features ofGeoPhotosare as follows:Extract metadata (timestamp, coordinates, etc.) from one or more files, and
write to a csv file if desiredPull coordinates from Google Takeout location historyPlot coordinate data on a fully customizable heatmap, including markers,
tooltips, layer control, and moreAnalyze coordinate data to determine unique countries, most common countries,
and moreHighlight certain countries on the heatmap easily and painlesslySave the map to an html file for reference or for use with web development
frameworks such asflaskOpen the html file directly from the code for debuggingHow to get itDependenciesRequired dependenciesCurrently, the following packages are required:pillowfoliumosgeoSome packages that are currently required may be made optional in the future,
such as thegdal/osgeopackage.Optional DependenciesThegeopandaspackage has been made
optional due to how difficult it is to install properly. It is required to
perform geographical data analysis.InstallationAssuming you've already got the dependencies covered, you can use pip to install
this package:pip install geophotosHowever, 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 geophotosThis should handle all of the dependencies for you, although you still might run
into some issues (I sure did!).UpdatingTo updategeophotosto the latest version, simply use the command:pip install --upgrade geophotosExample usageHeatmap from photo locationsOne 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:Read latitudes and longitudes from a csv fileGenerate a heatmap using this coordinate dataAdd a marker that marks my hometownAnalyze the data and determine which countries I've visitedHighlight only the countries I've been to on a separate layerSave the map as an html file and open it in a web browserThe html file is completely interactive, and I hope to eventually use it on my
personal website.importgeophotosasgp# Read coordinate data from csvdata=gp.coordinates_from_csv(r'coordinates.csv',2,3)# Initialize the Map objectnys_center=[42.965000,-76.016667]heatmap=gp.Map(location=nys_center,zoom_start=7)# Feed the Heatmap object the coordinatesheatmap.coordinates=data# Create the heatmapheatmap.create_heatmap(max_zoom=10,min_opacity=0.05,radius=13,blur=25,name='Photo Heatmap')# Add a marker to the heatmaphamburg_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 uniqueanalyzer=gp.Analyzer(data)unique_countries=analyzer.unique_countries(),# Use the data to determine which countries to highlightborder_layer=gp.CountryLayer(unique_countries,name='Countries Visited')border_layer.add_to(heatmap)# Add layer control functionality to the mapheatmap.add_layer_control()# Save the heatmap and open it in a browserheatmap.save_html('sample.html',open_html=True)Heatmap from Google Takeout location historyAnother 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
withoutGeoPhotos, 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.importgeophotosasgp# Read coordinate data from the location history filedata=gp.coordinates_from_google_takeout_json(r'locationhistory.json')# Initialize the Map objectnys_center=[42.965000,-76.016667]heatmap=gp.Map(location=nys_center,zoom_start=7)# Feed the Heatmap object the coordinatesheatmap.coordinates=data# Create the heatmapheatmap.create_heatmap(max_zoom=14,min_opacity=0.05,radius=13,blur=25)# Save the heatmap and open it in a browserheatmap.save_html(r'locationhistory.html',open_html=True)AuthorsJake Brehm-Initial Work-Email|Github|LinkedIn