maps.chandlerswift.com/layers/dot-cams/al/get_data.py

32 lines
660 B
Python
Raw Normal View History

2024-01-30 00:22:08 -06:00
#!/usr/bin/python3
import requests
import json
cameras = []
res = requests.get("https://api.algotraffic.com/v3.0/Cameras")
res.raise_for_status()
for c in res.json():
cameras.append({
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [c['location']['longitude'], c['location']['latitude']], # yes, [lon, lat] since it's [x, y]
},
"properties": {
'originalData': c,
},
})
geojson = {
"type": "FeatureCollection",
"features": cameras,
}
with open("data.geojson", "w") as f:
f.write(json.dumps(geojson))
print(f"{len(cameras)} locations found")