Skip to content

Commit

Permalink
updated plotting information
Browse files Browse the repository at this point in the history
- now also rest of eur map
  • Loading branch information
harivyasi committed Aug 16, 2023
1 parent e9638fc commit cc0bd50
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/map_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ jobs:
bash download_prerequistes.sh
python generate_map.py
python generate_map.py germany
python generate_map.py nogermany
- name: Release Map
uses: "softprops/action-gh-release@v1"
if: startsWith(github.ref, 'refs/tags/')
with:
token: "${{ secrets.GITHUB_TOKEN }}"
files: |
germany.svg
restofeur.svg
europe.svg
map.html
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ data/*.geojson
.mapenv
# output files
map.html
europe.*
germany.*
*.svg
*.png
*.jpg
# .vscode folder
.vscode
141 changes: 123 additions & 18 deletions data/plotted_locations.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
{
"common_name": "Zürich",
"id_name": "Zürich",
"stage": "Mixed",
"num_users": 4,
"stage": "Production",
"num_users": 1,
"country_code": "CH"
},
{
Expand All @@ -20,38 +20,87 @@
"num_users": 4,
"country_code": "DE"
},
{
"common_name": "Berlin",
"id_name": "Berlin",
"stage": "Planned",
"num_users": 4,
"country_code": "DE"
},
{
"common_name": "Bielefeld",
"id_name": "Bielefeld, Kreisfreie Stadt",
"stage": "Test",
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Bonn",
"id_name": "Bonn, Kreisfreie Stadt",
"stage": "Mixed",
"num_users": 2,
"country_code": "DE"
},
{
"common_name": "Braunschweig",
"id_name": "Braunschweig, Kreisfreie Stadt",
"stage": "Test",
"stage": "Production",
"num_users": 2,
"country_code": "DE"
},
{
"common_name": "Colonge",
"id_name": "Köln, Kreisfreie Stadt",
"stage": "Production",
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Chemnitz",
"id_name": "Chemnitz, Kreisfreie Stadt",
"stage": "Production",
"num_users": 1,
"num_users": 2,
"country_code": "DE"
},
{
"common_name": "Dresden",
"id_name": "Dresden, Kreisfreie Stadt",
"stage": "Test",
"stage": "Production",
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Duisburg-Essen",
"id_name": "Duisburg, Kreisfreie Stadt",
"stage": "Test",
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Düsseldorf",
"id_name": "Düsseldorf, Kreisfreie Stadt",
"stage": "Production",
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Frankfurt",
"id_name": "Frankfurt am Main, Kreisfreie Stadt",
"stage": "Production",
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Freiburg",
"id_name": "Freiburg im Breisgau, Stadtkreis",
"stage": "Test",
"stage": "Production",
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Geesthacht",
"id_name": "Herzogtum Lauenburg",
"stage": "Planned",
"num_users": 1,
"country_code": "DE"
},
Expand All @@ -62,6 +111,20 @@
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Halle",
"id_name": "Halle (Saale), Kreisfreie Stadt",
"stage": "Production",
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Hannover",
"id_name": "Region Hannover",
"stage": "Planned",
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Heidelberg",
"id_name": "Heidelberg, Stadtkreis",
Expand All @@ -87,35 +150,49 @@
"common_name": "Karlsruhe",
"id_name": "Karlsruhe, Stadtkreis",
"stage": "Mixed",
"num_users": 5,
"num_users": 6,
"country_code": "DE"
},
{
"common_name": "Kiel",
"id_name": "Kiel, Kreisfreie Stadt",
"stage": "Test",
"stage": "Production",
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Colonge",
"id_name": "Köln, Kreisfreie Stadt",
"stage": "Test",
"common_name": "Konstanz",
"id_name": "Konstanz",
"stage": "Production",
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Leipzig",
"id_name": "Leipzig",
"stage": "Production",
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Mainz",
"id_name": "Mainz, Kreisfreie Stadt",
"stage": "Test",
"stage": "Production",
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Munich",
"id_name": "München, Kreisfreie Stadt",
"stage": "Mixed",
"num_users": 1,
"num_users": 3,
"country_code": "DE"
},
{
"common_name": "Münster",
"id_name": "Münster, Kreisfreie Stadt",
"stage": "Production",
"num_users": 2,
"country_code": "DE"
},
{
Expand All @@ -126,16 +203,23 @@
"country_code": "DE"
},
{
"common_name": "Stuttgart",
"id_name": "Stuttgart, Stadtkreis",
"common_name": "Regensburg",
"id_name": "Regensburg, Kreisfreie Stadt",
"stage": "Production",
"num_users": 2,
"country_code": "DE"
},
{
"common_name": "Ulm",
"id_name": "Ulm, Stadtkreis",
"stage": "Planned",
"common_name": "Rostock",
"id_name": "Landkreis Rostock",
"stage": "Production",
"num_users": 1,
"country_code": "DE"
},
{
"common_name": "Stuttgart",
"id_name": "Stuttgart, Stadtkreis",
"stage": "Production",
"num_users": 1,
"country_code": "DE"
},
Expand Down Expand Up @@ -180,5 +264,26 @@
"stage": "Planned",
"num_users": 1,
"country_code": "IN"
},
{
"common_name": "London",
"id_name": "Camden and City of London",
"stage": "Planned",
"num_users": 1,
"country_code": "UK"
},
{
"common_name": "Lexington",
"id_name": "Lexington",
"stage": "Planned",
"num_users": 1,
"country_code": "US"
},
{
"common_name": "Oakland",
"id_name": "Oakland",
"stage": "Planned",
"num_users": 1,
"country_code": "US"
}
]
30 changes: 21 additions & 9 deletions generate_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# no need to change unless changes in apprearance are required. Please know what you are doing.
# static map only for Germany, not other european countries
only_germany = len(sys.argv) > 1 and sys.argv[1] == "germany"
no_germany = len(sys.argv) > 1 and sys.argv[1] == "nogermany"
color = {"Production": "green", # color codes for different types of instances
"Mixed": "blue", # color supported in dynamic map are listed here https://github.com/pointhi/leaflet-color-markers
"Test": "orange",
Expand All @@ -25,8 +26,12 @@
legend_location = (0.2, 0.7)
color_based_on = "NUTS_NAME"
map_filename = "germany.svg"
elif no_germany:
legend_location = (0.7, 0.3)
color_based_on = "CNTR_CODE"
map_filename = "restofeur.svg"
else:
legend_location = (1.0, 0.4)
legend_location = (0.7, 0.3)
color_based_on = "CNTR_CODE"
map_filename = "europe.svg"

Expand Down Expand Up @@ -54,6 +59,15 @@
eur_country = eur_country[eur_country.CNTR_CODE.isin(
locations["country_code"].unique().tolist())]
eur_country_list = eur_country.CNTR_CODE.unique().tolist()
if no_germany:
eur_country.drop(
eur_country[eur_country.CNTR_CODE.isin(["DE"])].index, inplace=True)
try:
eur_country_list.remove("DE")
except ValueError:
pass
if not len(eur_country_list):
print("WARNING: No European to be plotted.")

# modifications to eur map, if any
# keep only mainland parts for conciseness
Expand Down Expand Up @@ -117,20 +131,18 @@

plt.axis('off')
plt.savefig(map_filename)
if only_germany:
if only_germany or no_germany:
exit() # exit after producing the static map

########################
# Plot the dynamic map #
########################

# opposite of what can happen so that the values are always overwritten
map_limits = {"lon": {}, "lat": {}}

map_limits["lat"]["max"] = locations.latitude.max() + dynamic_map_padding
map_limits["lat"]["min"] = locations.latitude.min() - dynamic_map_padding
map_limits["lon"]["max"] = locations.longitude.max() + dynamic_map_padding
map_limits["lon"]["min"] = locations.longitude.min() - dynamic_map_padding
# limits of the dynamic
map_limits = {"lon": {"max": locations.longitude.max() + dynamic_map_padding,
"min": locations.longitude.min() - dynamic_map_padding},
"lat": {"max": locations.latitude.max() + dynamic_map_padding,
"min": locations.latitude.min() - dynamic_map_padding}}

# load templated text for the dynamic map
html_text = (data_dir / "template.html").read_text()
Expand Down

0 comments on commit cc0bd50

Please sign in to comment.