maps.chandlerswift.com/layers/chains/krispy-kreme/get_data.py

38 lines
992 B
Python
Raw Normal View History

2023-07-24 22:52:40 -05:00
#!/usr/bin/env python3
import requests
import re
import json
res = requests.get('https://api.krispykreme.com/shops/?latitude=44.7601&longitude=-93.2748&count=1000&shopFeatureFlags=0&includeGroceryStores=false&includeShops=true')
locations = json.loads(res.text)
stores = []
for location in locations:
stores.append({
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [float(location['longitude']), float(location['latitude'])], # yes, [lon, lat] since it's [x, y]
},
"properties": {
'address': location['address1'].title(),
'city': location['city'].title(),
'state': location['state'],
'zip': location['zipCode'],
'website': location['pagesUrl'],
},
})
geojson = {
"type": "FeatureCollection",
"features": stores,
}
with open("data.geojson", "w") as f:
2023-07-24 22:52:40 -05:00
f.write(json.dumps(geojson))
print(f"{len(locations)} locations found")