Move chains to their own directory
This commit is contained in:
parent
f3f7a21645
commit
c74edcb8c0
21 changed files with 50 additions and 40 deletions
37
layers/chains/krispy-kreme/get_data.py
Executable file
37
layers/chains/krispy-kreme/get_data.py
Executable file
|
|
@ -0,0 +1,37 @@
|
|||
#!/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("krispy-kreme-data.geojson", "w") as f:
|
||||
f.write(json.dumps(geojson))
|
||||
|
||||
print(f"{len(locations)} locations found")
|
||||
Loading…
Add table
Add a link
Reference in a new issue