Slippy Map Regionalizer Example¶
In [1]:
Copied!
import geopandas as gpd
from shapely import geometry
from srai.regionalizers import SlippyMapRegionalizer
from srai.plotting.folium_wrapper import plot_regions
from srai.constants import WGS84_CRS
import geopandas as gpd
from shapely import geometry
from srai.regionalizers import SlippyMapRegionalizer
from srai.plotting.folium_wrapper import plot_regions
from srai.constants import WGS84_CRS
Define starting polygons¶
In [2]:
Copied!
gdf = gpd.GeoDataFrame(
geometry=[
geometry.Polygon(
shell=[
(-1, 0),
(0, 0.5),
(1, 0),
(1, 1),
(0, 1),
],
holes=[
[
(0.8, 0.9),
(0.9, 0.55),
(0.8, 0.3),
(0.5, 0.4),
]
],
),
geometry.Polygon(shell=[(-0.25, 0), (0.25, 0), (0, 0.2)]),
],
crs=WGS84_CRS,
)
gdf.explore()
gdf = gpd.GeoDataFrame(
geometry=[
geometry.Polygon(
shell=[
(-1, 0),
(0, 0.5),
(1, 0),
(1, 1),
(0, 1),
],
holes=[
[
(0.8, 0.9),
(0.9, 0.55),
(0.8, 0.3),
(0.5, 0.4),
]
],
),
geometry.Polygon(shell=[(-0.25, 0), (0.25, 0), (0, 0.2)]),
],
crs=WGS84_CRS,
)
gdf.explore()
Out[2]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Define tile resolution¶
In [3]:
Copied!
zoom = 12
zoom = 12
Regionalize using SlippyMapRegionalizer¶
In [4]:
Copied!
regionalizer = SlippyMapRegionalizer(zoom)
gdf_slippy = regionalizer.transform(gdf)
folium_map = gdf.explore()
plot_regions(gdf_slippy, colormap=["red"], map=folium_map)
regionalizer = SlippyMapRegionalizer(zoom)
gdf_slippy = regionalizer.transform(gdf)
folium_map = gdf.explore()
plot_regions(gdf_slippy, colormap=["red"], map=folium_map)
Out[4]:
Make this Notebook Trusted to load map: File -> Trust Notebook