Merge pull request #3 from netzbegruenung/upgradeMaps

Upgrade maps
This commit is contained in:
mehlukas 2019-09-18 13:19:34 +02:00 committed by GitHub
commit fdde736b91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 21023 additions and 104393 deletions

View file

@ -30,6 +30,8 @@ MAPPING = {"Neustadt a.d. Aisch-Bad Windsheim": "Neustadt-Aisch",
"Kaufbeuren": "Ostallgäu",
"Ostallgäu": "Ostallgäu"}
REMOVE_BW = ["08215", "08226", "08136", "08436"]
def createLVBasemap():
green_data = []
for entry in dir_entries():
@ -45,7 +47,10 @@ def createLVBasemap():
name = feature["properties"]["GEN"]
for d in green_data:
if d["state"] == name:
feature["properties"]["green-data"] = d
feature["properties"] = {}
feature["properties"]["type"] = d["type"]
feature["properties"]["level"] = d["level"]
feature["properties"]["state"] = d["state"]
result_map["features"].append(feature)
with open("maps/lv_basemap.geojson", "w", encoding='utf-8') as output_f:
json.dump(result_map, output_f, indent=4)
@ -56,6 +61,23 @@ def initialize():
with open("maps/landkreise_simplify200.geojson") as map_f:
map_data = json.load(map_f)["features"]
# add additional bw data:
map_data_copy = []
for feature in map_data:
if feature["properties"]["SN_L"] == "08" and feature["properties"]["RS"] in REMOVE_BW:
pass # don't add it
else:
map_data_copy.append(feature)
map_data = map_data_copy
with open("maps/additional_bw.geojson") as map_f:
map_data2 = json.load(map_f)["features"]
for feature in map_data2:
feature["properties"]["GEN"] = feature["properties"]["kvname"]
feature["properties"]["NBD"] = ""
feature["properties"]["BEZ"] = ""
feature["properties"]["SN_L"] = "08"
map_data += map_data2
for entry in dir_entries():
if entry["type"] == "REGIONAL_CHAPTER":
if entry["level"] == "DE:KREISVERBAND":
@ -254,7 +276,11 @@ def createKVBasemap():
else:
# skip not-matched map parts
continue
feature["properties"]["green-data"] = entry
feature["properties"] = {}
feature["properties"]["type"] = entry["type"]
feature["properties"]["level"] = entry["level"]
feature["properties"]["state"] = entry["state"]
feature["properties"]["district"] = entry["district"]
result_features.append(feature)
result_map = {"type": "FeatureCollection",
"features": result_features}

2046
maps/additional_bw.geojson Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -12,13 +12,13 @@ def updateMaps(level="lv"):
tw_max = 0
in_max = 0
for feature in map_data["features"]:
greendata = feature["properties"]["green-data"]
key = "//".join([greendata["type"], greendata["level"], greendata["state"], greendata.get("district", ""), greendata.get("city", "")])
p = feature["properties"]
key = "//".join([p["type"], p["level"], p["state"], p.get("district", ""), p.get("city", "")])
result = data.get(key)
print(result)
social_data = {}
if result:
_, _, _ , _, _, fb_name, fb_count, tw_name, tw_count, in_name, in_count = data.get(key)
_, _, _ , _, _, fb_name, fb_count, tw_name, tw_count, in_name, in_count = result
if fb_count > fb_max:
fb_max = fb_count
if tw_count > tw_max:
@ -34,11 +34,10 @@ def updateMaps(level="lv"):
feature["properties"].update(social_data)
print(fb_max, tw_max, in_max)
plattform = "fb"
for plattform, maxval, col in zip(["fb", "tw", "in"], [fb_max, tw_max, in_max], ["#3664a2", "#55acee", "#d02e92"]):
for feature in map_data["features"]:
count = feature["properties"].get(plattform + "_count", 0)
if level=="lv":
if level == "lv":
# linear for LV
feature["properties"]["fill-opacity"] = count/maxval
elif level == "kv":