Note
Click here to download the full example code
Customize Salem maps¶
How to change the look of a Map?
Out:
/home/docs/checkouts/readthedocs.org/user_builds/salem/conda/v0.3.6/lib/python3.8/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
vertices = concatenate([
/home/docs/checkouts/readthedocs.org/user_builds/salem/conda/v0.3.6/lib/python3.8/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
[asarray(r)[:, :2] for r in t.interiors])
/home/docs/checkouts/readthedocs.org/user_builds/salem/conda/v0.3.6/lib/python3.8/site-packages/salem/graphics.py:720: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
for gg in g:
/home/docs/checkouts/readthedocs.org/user_builds/salem/conda/v0.3.6/lib/python3.8/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
vertices = concatenate([
/home/docs/checkouts/readthedocs.org/user_builds/salem/conda/v0.3.6/lib/python3.8/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
[asarray(r)[:, :2] for r in t.interiors])
/home/docs/checkouts/readthedocs.org/user_builds/salem/conda/v0.3.6/lib/python3.8/site-packages/salem/graphics.py:689: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
return self.set_shapefile(shapefiles['rivers'], **kwargs)
/home/docs/checkouts/readthedocs.org/user_builds/salem/conda/v0.3.6/lib/python3.8/site-packages/salem/graphics.py:733: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
for gg in g:
/home/docs/checkouts/readthedocs.org/user_builds/salem/conda/v0.3.6/lib/python3.8/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
vertices = concatenate([
/home/docs/checkouts/readthedocs.org/user_builds/salem/conda/v0.3.6/lib/python3.8/site-packages/salem/graphics.py:1147: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
plot_polygon(ax, g, **kwargs) # was g.buffer(0). Why?
/home/docs/checkouts/readthedocs.org/user_builds/salem/conda/v0.3.6/lib/python3.8/site-packages/salem/graphics.py:355: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
out = self.plot(ax)
import salem
import matplotlib.pyplot as plt
# get the map from a WRF file
ds = salem.open_wrf_dataset(salem.get_demo_file('wrfout_d01.nc'))
smap = ds.salem.get_map(countries=False)
# Change the country borders
smap.set_shapefile(countries=True, color='C3', linewidths=2)
# Add oceans and lakes
smap.set_shapefile(oceans=True)
smap.set_shapefile(rivers=True)
smap.set_shapefile(lakes=True, facecolor='blue', edgecolor='blue')
# Change the lon-lat countour setting
smap.set_lonlat_contours(add_ytick_labels=False, interval=5, linewidths=1.5,
linestyles='-', colors='C1')
# Add a scalebar (experimental)
smap.set_scale_bar(location=(0.87, 0.04), add_bbox=True)
# done!
smap.visualize()
plt.show()
Total running time of the script: ( 0 minutes 9.866 seconds)