/srv/conda/envs/notebook/lib/python3.10/site-packages/owslib/wmts.py:860: FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.
if current and current.text == 'true':
/srv/conda/envs/notebook/lib/python3.10/site-packages/owslib/wmts.py:657: RuntimeWarning: TileMatrixLimits with tileMatrix "1" already exists
warnings.warn(msg, RuntimeWarning)
/srv/conda/envs/notebook/lib/python3.10/site-packages/owslib/wmts.py:657: RuntimeWarning: TileMatrixLimits with tileMatrix "2" already exists
warnings.warn(msg, RuntimeWarning)
/srv/conda/envs/notebook/lib/python3.10/site-packages/owslib/wmts.py:657: RuntimeWarning: TileMatrixLimits with tileMatrix "3" already exists
warnings.warn(msg, RuntimeWarning)
/srv/conda/envs/notebook/lib/python3.10/site-packages/owslib/wmts.py:657: RuntimeWarning: TileMatrixLimits with tileMatrix "4" already exists
warnings.warn(msg, RuntimeWarning)
/srv/conda/envs/notebook/lib/python3.10/site-packages/owslib/wmts.py:657: RuntimeWarning: TileMatrixLimits with tileMatrix "5" already exists
warnings.warn(msg, RuntimeWarning)
/srv/conda/envs/notebook/lib/python3.10/site-packages/owslib/wmts.py:657: RuntimeWarning: TileMatrixLimits with tileMatrix "6" already exists
warnings.warn(msg, RuntimeWarning)
Load and subset Populated Places from Natural Earth
import cartopy.io.shapereader as shprimport geopandas as gpdfname = shpr.natural_earth(resolution='10m', category='cultural', name='populated_places')gdf = gpd.read_file(fname).to_crs(ax.projection.proj4_init) # load and convert to CRS
gdf = gdf[gdf.geometry.within(box(*[ax.get_extent()[i] for i in [0,2,1,3]]))]
gdf["plot_code"] = gdf["FEATURECLA"].isin(['Admin-1 capital', 'Admin-1 region capital', 'Admin-0 region capital', 'Admin-0 capital', 'Admin-0 capital alt'])
def add_cities(grouper, ax=None, marker=None, annotate=None, color=None, markersize=None, fontsize=None):"""Adds cities and lebels by group to a plot"""ifnot ax: ax = plt.gca() ngroup = grouper.ngroupsifnot marker: marker = [marker] * ngroup # Create an array of markersifnot annotate: annotate = [annotate] * ngroupifnot color: color = [color] * ngroupifnot markersize: markersize = [markersize] * ngroupifnot fontsize: fontsize = [fontsize] * ngroupfor (name, group), mrkr, ann, c, ms, fs inzip(gdf.groupby("plot_code"), marker, annotate, color, markersize, fontsize): group.plot(ax=ax, marker=mrkr, color=c, markersize=ms)if ann:for x, y, label inzip(group.geometry.x, group.geometry.y, group.NAME): ax.annotate(label, xy=(x, y), xytext=(3, 3), textcoords="offset points", fontsize=fs)