monet.plots.mapgen
Map utilities.
Functions
|
Draw a map with Cartopy. |
- monet.plots.mapgen.draw_map(*, crs=None, natural_earth=False, coastlines=True, states=False, counties=False, countries=True, resolution='10m', extent=None, figsize=(10, 5), linewidth=0.25, return_fig=False, **kwargs)
Draw a map with Cartopy.
Creates a map using Cartopy with configurable features like coastlines, borders, and natural earth elements. This function simplifies the process of creating maps for spatial visualization.
- Parameters:
crs (cartopy.crs.Projection) – The map projection. If set, this takes precedence over the possible
kwargs['subplot_kw']['projection']. If unset (None), defaults toccrs.PlateCarree().natural_earth (bool) – Add the Cartopy Natural Earth ocean, land, lakes, and rivers features.
coastlines (bool) – Add coastlines (linewidth applied).
states (bool) – Add states/provinces (linewidth applied).
counties (bool) – Add US counties (linewidth applied).
countries (bool) – Add country borders (linewidth applied).
resolution ({‘10m’, ‘50m’, ‘110m’}) – The resolution of the Natural Earth features for coastlines, states, and counties. Higher resolution (e.g., ‘10m’) provides more detail but may be slower to render.
extent (array-like) – Set the map extent with
[lon_min,lon_max,lat_min,lat_max].figsize (tuple) – Figure size (width, height), passed to
plt.subplots(). This takes precedence over the possiblekwargs['figsize'].linewidth (float) – Line width for coastlines, states, counties, and countries.
return_fig (bool) – Return the figure and axes objects. By default (
False), just the axes object is returned.**kwargs – Arguments to pass to
plt.subplots().
- Returns:
By default, returns just the
ax(cartopy.mpl.geoaxes.GeoAxesinstance). If return_fig is true, returns a tuple of(fig, ax)wherefigis the matplotlib Figure instance andaxis the GeoAxes instance.- Return type:
Notes
The ‘10m’ resolution provides the most detailed features but can be slow for large or global maps. ‘50m’ is a good compromise for regional maps, while ‘110m’ works well for global views.
Examples
>>> # Create a simple map with coastlines >>> ax = draw_map(coastlines=True, resolution='50m')
>>> # Create a detailed US map with states and counties >>> ax = draw_map( ... crs=ccrs.AlbersEqualArea(central_longitude=-95), ... states=True, ... counties=True, ... resolution='10m', ... extent=[-125, -65, 25, 50] ... )