Skip to content

Commit

Permalink
Create Choropleth of region and municipalities
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcth committed May 5, 2024
1 parent 9cb11e8 commit 4a07092
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions scripts/choropleth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Choropleth module."""

import geopandas as gpd
from shapely import geometry, ops, polygonize

riksgrans = gpd.read_file("04_riksgrans.geojson", use_arrow=True, engine="pyogrio")
sjograns = gpd.read_file(
"05_sjoterritoriets_grans_i_havet.geojson", use_arrow=True, engine="pyogrio"
)
lansgrans = gpd.read_file("02_lansgrans.geojson", use_arrow=True, engine="pyogrio")
kommungrans = gpd.read_file("01_kommungrans.geojson", use_arrow=True, engine="pyogrio")

# 21 regions
lans = ops.linemerge(
geometry.MultiLineString(
sjograns.geometry.to_list()
+ riksgrans.geometry.to_list()
+ lansgrans.geometry.to_list()
)
)

# 290 municipalities
kommuns = ops.linemerge(
geometry.MultiLineString(
sjograns.geometry.to_list()
+ riksgrans.geometry.to_list()
+ kommungrans.geometry.to_list()
)
)

len(polygonize(lans.geoms).geoms)

0 comments on commit 4a07092

Please sign in to comment.