Add Alabama DOT cameras
This commit is contained in:
parent
fcdb56877f
commit
4f816352b5
3 changed files with 98 additions and 0 deletions
31
layers/dot-cams/al/get_data.py
Executable file
31
layers/dot-cams/al/get_data.py
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
#!/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")
|
||||
Loading…
Add table
Add a link
Reference in a new issue