-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseLocations.py
More file actions
28 lines (24 loc) · 827 Bytes
/
parseLocations.py
File metadata and controls
28 lines (24 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json
# open geojson file from QGIS
with open('pointpoly.geojson') as data_file:
data = json.load(data_file)
# convert to format parseable by Uber API
locations = []
count = 1
for item in data["features"]:
point = dict()
point["id"] = item["properties"]["id"]
if point["id"] == 0: # select one point from each neighborhood in QGIS map
print(item)
point["OBJECTID"] = item["properties"]["OBJECTID"]
point["latitude"] = item["geometry"]["coordinates"][1]
point["longitude"] = item["geometry"]["coordinates"][0]
point["location_id"] = count
locations.append(point)
count += 1
print(point)
result = json.dumps(locations)
# write as array of locations to config file
with open("config.conf", "a+") as myfile:
if "locations" not in myfile.read():
myfile.write("\n"+"locations = "+str(result))