Initial commit
This commit is contained in:
commit
73ea6a9413
26 changed files with 58556 additions and 0 deletions
31
scripts/add-geolocation-to-images.py
Executable file
31
scripts/add-geolocation-to-images.py
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell --quiet -p nix-eval-jobs -p nix -p python3 -p python3Packages.pillow -i python
|
||||
|
||||
import json
|
||||
import os
|
||||
from PIL import Image
|
||||
from PIL.ExifTags import TAGS
|
||||
|
||||
# https://stackoverflow.com/a/78462781
|
||||
GPSINFO_TAG = next(
|
||||
tag for tag, name in TAGS.items() if name == "GPSInfo"
|
||||
)
|
||||
def decimal_coords(coords, ref):
|
||||
decimal_degrees = float(coords[0]) + float(coords[1]) / 60 + float(coords[2]) / 3600
|
||||
if ref == "S" or ref =='W' :
|
||||
decimal_degrees = -1 * decimal_degrees
|
||||
return decimal_degrees
|
||||
|
||||
with open('data/data.json') as f:
|
||||
data = json.loads(f.read())
|
||||
|
||||
for i, stand in enumerate(data['stands']):
|
||||
lats = []
|
||||
lons = []
|
||||
for view_image in stand['view']:
|
||||
im = Image.open(os.path.join('images', view_image))
|
||||
gpsinfo = im.getexif().get_ifd(GPSINFO_TAG)
|
||||
lats.append(decimal_coords(gpsinfo[2], gpsinfo[1]))
|
||||
lons.append(decimal_coords(gpsinfo[4], gpsinfo[3]))
|
||||
data['stands'][i]['location'] = [sum(lats)/len(lats), sum(lons)/len(lons)] # TODO: round
|
||||
print(json.dumps(data, indent=4))
|
||||
40
scripts/get_plats.py
Executable file
40
scripts/get_plats.py
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell --quiet -p python3 -p python3Packages.requests -i python
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
import requests
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
raise "Wrong number of args. Use: `get_plats.py out_file.json`"
|
||||
|
||||
URL = "https://maps-test.co.itasca.mn.us/ArcGIS/rest/services/WAB_Maps/PublicOperationLayers/MapServer/30/query"
|
||||
|
||||
params={
|
||||
"f": "geojson",
|
||||
"returnGeometry": "true",
|
||||
"spatialRel": "esriSpatialRelIntersects",
|
||||
# {"xmin":-10397214.368951382,"ymin":6023763.834217183,"xmax":-10397185.705065776,"ymax":6023792.498102792,"spatialReference":{"wkid":102100}}
|
||||
# {"xmin":-10395523.199700572,"ymin":6021824.244624444,"xmax":-10395465.871929357,"ymax":6021881.572395659,"spatialReference":{"wkid":102100}}
|
||||
"geometry": json.dumps({
|
||||
# "xmin": -10397313.413735004,
|
||||
# "ymin": 6024888.239059315,
|
||||
# "xmax": -10395148.64317237,
|
||||
# "ymax": 6021777.960551391,
|
||||
"xmin": -10397214.368951382,
|
||||
"xmax": -10395465.871929357,
|
||||
"ymin": 6021824.244624444,
|
||||
"ymax": 6023792.498102792,
|
||||
"spatialReference": {
|
||||
"wkid": '102100'
|
||||
},
|
||||
}),
|
||||
"geometryType": "esriGeometryEnvelope",
|
||||
"inSR": "102100",
|
||||
"outFields": "TAO_NAME",
|
||||
"outSR": "EPSG:4326"
|
||||
}
|
||||
|
||||
with open(sys.argv[1], 'w') as f:
|
||||
f.write(requests.get(URL, params=params).text)
|
||||
Loading…
Add table
Add a link
Reference in a new issue