242 lines
5.6 KiB
Markdown
242 lines
5.6 KiB
Markdown
|
|
# Name ideas
|
|
dozo
|
|
fog
|
|
mtool
|
|
ordigi
|
|
|
|
# Geocoders
|
|
- Pelias
|
|
- Photon
|
|
- Nominatium
|
|
|
|
# TEST
|
|
|
|
def get_exif(filename):
|
|
image = Image.open(filename)
|
|
image.verify()
|
|
return image._getexif()
|
|
|
|
def get_geotagging(exif):
|
|
if not exif:
|
|
raise ValueError("No EXIF metadata found")
|
|
|
|
geotagging = {}
|
|
for (idx, tag) in TAGS.items():
|
|
if tag == 'GPSInfo':
|
|
if idx not in exif:
|
|
raise ValueError("No EXIF geotagging found")
|
|
|
|
for (key, val) in GPSTAGS.items():
|
|
if key in exif[idx]:
|
|
geotagging[val] = exif[idx][key]
|
|
|
|
return geotagging
|
|
get_geotagging(exif)
|
|
from PIL.ExifTags import TAGS
|
|
|
|
def get_labeled_exif(exif):
|
|
labeled = {}
|
|
for (key, val) in exif.items():
|
|
labeled[TAGS.get(key)] = val
|
|
|
|
return labeled
|
|
get_geotagging(exif)
|
|
from PIL.ExifTags import GPSTAGS
|
|
get_geotagging(exif)
|
|
geotags = get_geotagging(exif)
|
|
get_location(geotags)
|
|
|
|
def get_decimal_from_dms(dms, ref):
|
|
|
|
degrees = dms[0][0] / dms[0][1]
|
|
minutes = dms[1][0] / dms[1][1] / 60.0
|
|
seconds = dms[2][0] / dms[2][1] / 3600.0
|
|
|
|
if ref in ['S', 'W']:
|
|
degrees = -degrees
|
|
minutes = -minutes
|
|
seconds = -seconds
|
|
|
|
return round(degrees + minutes + seconds, 5)
|
|
|
|
def get_coordinates(geotags):
|
|
lat = get_decimal_from_dms(geotags['GPSLatitude'], geotags['GPSLatitudeRef'])
|
|
|
|
lon = get_decimal_from_dms(geotags['GPSLongitude'], geotags['GPSLongitudeRef'])
|
|
|
|
return (lat,lon)
|
|
|
|
def get_geotagging(exif):
|
|
if not exif:
|
|
raise ValueError("No EXIF metadata found")
|
|
|
|
geotagging = {}
|
|
for (idx, tag) in TAGS.items():
|
|
if tag == 'GPSInfo':
|
|
if idx not in exif:
|
|
raise ValueError("No EXIF geotagging found")
|
|
|
|
for (key, val) in GPSTAGS.items():
|
|
if key in exif[idx]:
|
|
geotagging[val] = exif[idx][key]
|
|
|
|
return geotagging
|
|
|
|
def get_decimal_from_dms(dms, ref):
|
|
|
|
degrees = dms[0]
|
|
minutes = dms[1] / 60.0
|
|
seconds = dms[2] / 3600.0
|
|
|
|
if ref in ['S', 'W']:
|
|
degrees = -degrees
|
|
minutes = -minutes
|
|
seconds = -seconds
|
|
|
|
return round(degrees + minutes + seconds, 5)
|
|
headers = {}
|
|
params = {
|
|
'apiKey': os.environ['API_KEY'],
|
|
'at': "%s,%s" % coords,
|
|
'lang': 'en-US',
|
|
'limit': 1,
|
|
}
|
|
78/41: headers = {}
|
|
78/42:
|
|
params = {
|
|
'apiKey': os.environ['API_KEY'],
|
|
'at': "%s,%s" % coords,
|
|
'lang': 'en-US',
|
|
'limit': 1,
|
|
}
|
|
78/43:
|
|
params = {
|
|
'apiKey': os.environ['API_KEY'],
|
|
'at': "%s,%s" % coords,
|
|
'lang': 'en-US',
|
|
'limit': 1,
|
|
}
|
|
78/44: API_KEY=m5aGo8xGe4LLhxeKZYpHr2MPXGN2aDhe
|
|
78/45: API_KEY='m5aGo8xGe4LLhxeKZYpHr2MPXGN2aDhe'
|
|
78/46:
|
|
params = {
|
|
'apiKey': os.environ['API_KEY'],
|
|
'at': "%s,%s" % coords,
|
|
'lang': 'en-US',
|
|
'limit': 1,
|
|
}
|
|
78/47: API_KEY='m5aGo8xGe4LLhxeKZYpHr2MPXGN2aDhe'
|
|
78/48:
|
|
params = {
|
|
'apiKey': os.environ['API_KEY'],
|
|
'at': "%s,%s" % coords,
|
|
'lang': 'en-US',
|
|
'limit': 1,
|
|
}
|
|
78/49:
|
|
params = {
|
|
'apiKey': os.environ['m5aGo8xGe4LLhxeKZYpHr2MPXGN2aDhe'],
|
|
'at': "%s,%s" % coords,
|
|
'lang': 'en-US',
|
|
'limit': 1,
|
|
}
|
|
78/50: %load_ext autotime
|
|
78/51:
|
|
import pandas as pd
|
|
import geopandas as gpd
|
|
import geopy
|
|
from geopy.geocoders import Nominatim
|
|
from geopy.extra.rate_limiter import RateLimiterimport matplotlib.pyplot as plt
|
|
import plotly_express as pximport tqdm
|
|
from tqdm._tqdm_notebook import tqdm_notebook
|
|
78/52:
|
|
import pandas as pd
|
|
import geopandas as gpd
|
|
import geopy
|
|
from geopy.geocoders import Nominatim
|
|
from geopy.extra.rate_limiter import RateLimiterimport matplotlib.pyplot as plt
|
|
import plotly_express as px
|
|
import pandas as pd
|
|
import geopandas as gpd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from PIL import Image
|
|
|
|
filename='2021-02-24_09-33-29-20210305_081001_01.mp4'
|
|
def get_exif(filename):
|
|
image = Image.open(filename)
|
|
image.verify()
|
|
return image._getexif()
|
|
exif=get_exif(filename)
|
|
|
|
from PIL.ExifTags import TAGS
|
|
from PIL.ExifTags import GPSTAGS
|
|
def get_geotagging(exif):
|
|
if not exif:
|
|
raise ValueError("No EXIF metadata found")
|
|
|
|
geotagging = {}
|
|
for (idx, tag) in TAGS.items():
|
|
if tag == 'GPSInfo':
|
|
if idx not in exif:
|
|
raise ValueError("No EXIF geotagging found")
|
|
|
|
for (key, val) in GPSTAGS.items():
|
|
if key in exif[idx]:
|
|
geotagging[val] = exif[idx][key]
|
|
|
|
return geotagging
|
|
geotags = get_geotagging(exif)
|
|
import os
|
|
import requests
|
|
|
|
def get_location(geotags):
|
|
coords = get_coordinates(geotags)
|
|
|
|
uri = 'https://revgeocode.search.hereapi.com/v1/revgeocode'
|
|
headers = {}
|
|
params = {
|
|
'apiKey': os.environ['API_KEY'],
|
|
'at': "%s,%s" % coords,
|
|
'lang': 'en-US',
|
|
'limit': 1,
|
|
}
|
|
|
|
response = requests.get(uri, headers=headers, params=params)
|
|
try:
|
|
response.raise_for_status()
|
|
return response.json()
|
|
|
|
except requests.exceptions.HTTPError as e:
|
|
print(str(e))
|
|
return {}
|
|
|
|
def get_coordinates(geotags):
|
|
lat = get_decimal_from_dms(geotags['GPSLatitude'], geotags['GPSLatitudeRef'])
|
|
|
|
lon = get_decimal_from_dms(geotags['GPSLongitude'], geotags['GPSLongitudeRef'])
|
|
|
|
return (lat,lon)
|
|
coords = get_coordinates(geotags)
|
|
import geopy
|
|
from geopy.geocoders import Nominatim
|
|
locator = Nominatim(user_agent='myGeocoder')
|
|
# coordinates ='53.480837, -2.244914'
|
|
lat='45.58339'
|
|
lon='4.79823'
|
|
coords = lat + ',' + lon
|
|
locator.reverse(coords)
|
|
location =locator.reverse(coords)
|
|
location.address.split(',')
|
|
city=location.address.split(',')[1].strip()
|
|
country=location.address.split(',')[7].strip()
|
|
location.raw
|
|
rint
|
|
country=location.raw['address']['country']
|
|
city=location.raw['address']['village']
|