mirror of
https://github.com/netzbegruenung/social-spider.git
synced 2024-05-05 04:03:41 +02:00
add script to create bundeslaender maps
This commit is contained in:
parent
afbc16644a
commit
f63a68d91e
35
createMaps.py
Normal file
35
createMaps.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
import json
|
||||
|
||||
|
||||
def createBundeslaenderMap(filename, column):
|
||||
with open("maps/bundeslaender_simplify200.geojson") as map_f:
|
||||
maps = json.load(map_f)
|
||||
with open("docs/result.json") as result_f:
|
||||
result = json.load(result_f)
|
||||
minimum = 1000000
|
||||
maximum = -1
|
||||
for _, elem in result.items():
|
||||
if elem[0] != "LV":
|
||||
continue
|
||||
if elem[column] < minimum:
|
||||
minimum = elem[column]
|
||||
if elem[column] > maximum:
|
||||
maximum = elem[column]
|
||||
print(maximum)
|
||||
for feature in maps["features"]:
|
||||
name = feature["properties"]["GEN"]
|
||||
for _, elem in result.items():
|
||||
if elem[0] != "LV":
|
||||
continue
|
||||
if elem[1] != name:
|
||||
continue
|
||||
feature["properties"]["fill-opacity"] = elem[column] / maximum
|
||||
feature["properties"]["fill"] = "#00ff00"
|
||||
with open("maps/bundeslaender_" + filename + ".geojson", "w") as output_f:
|
||||
json.dump(maps, output_f)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
createBundeslaenderMap("facebookLikes", 5)
|
||||
createBundeslaenderMap("twitterFollower", 7)
|
||||
createBundeslaenderMap("instaFollower", 9)
|
1
maps/bundeslaender_facebookLikes.geojson
Normal file
1
maps/bundeslaender_facebookLikes.geojson
Normal file
File diff suppressed because one or more lines are too long
1
maps/bundeslaender_instaFollower.geojson
Normal file
1
maps/bundeslaender_instaFollower.geojson
Normal file
File diff suppressed because one or more lines are too long
1
maps/bundeslaender_simplify200.geojson
Normal file
1
maps/bundeslaender_simplify200.geojson
Normal file
File diff suppressed because one or more lines are too long
1
maps/bundeslaender_twitterFollower.geojson
Normal file
1
maps/bundeslaender_twitterFollower.geojson
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue