Maps

class eomaps.Maps(crs=None, layer='base', f=None, ax=None, preferred_wms_service='wms', **kwargs)

The base-class for generating plots with EOmaps.

See also

MapsGrid

Initialize a grid of Maps objects

Maps.new_layer

Get a Maps-object that represents a new layer on the map

Parameters
  • crs (int or a cartopy-projection, optional) –

    The projection of the map. If int, it is identified as an epsg-code Otherwise you can specify any projection supported by cartopy.crs A list for easy-accses is available as Maps.CRS

    The default is 4326.

  • layer (str, optional) – The name of the plot-layer assigned to this Maps-object. The default is β€œbase”.

  • f (matplotlib.Figure, optional) –

    Explicitly specify the matplotlib figure instance to use. (ONLY useful if you want to add a map to an already existing figure!)

    • If None, a new figure will be created (accessible via m.f)

    • Connected maps-objects will always share the same figure! You do NOT need to specify it (just provide the parent and you’re fine)!

    The default is None

  • ax (int, list, tuple, matplotlib.Axes, matplotlib.gridspec.SubplotSpec or None) –

    Explicitly specify the position of the axes or use already existing axes.

    Possible values are:

    • None:

      Initialize a new axes at the center of the figure (the default)

    • A tuple of 4 floats (left, bottom, width, height)

      The absolute position of the axis in relative figure-coordinates (e.g. in the range [0 , 1]) NOTE: since the axis-size is dependent on the plot-extent, the size of the map will be adjusted to fit in the provided bounding-box.

    • A tuple of 3 integers (nrows, ncols, index)

      The map will be positioned at the index position of a grid with nrows rows and ncols columns. index starts at 1 in the upper left corner and increases to the right. index can also be a two-tuple specifying the (first, last) indices (1-based, and including last) of the subplot, e.g., ax = (3, 1, (1, 2)) makes a map that spans the upper 2/3 of the figure.

    • A 3-digit integer

      Same as using a tuple of three single-digit integers. (e.g. 111 is the same as (1, 1, 1) )

    • matplotilb.gridspec.SubplotSpec:

      Use the SubplotSpec for initializing the axes.

    • matplotilb.Axes:

      Directly use the provided figure and axes instances for plotting. NOTE: The axes MUST be a geo-axes with m.crs_plot projection!

  • preferred_wms_service (str, optional) – Set the preferred way for accessing WebMap services if both WMS and WMTS capabilities are possible. The default is β€œwms”

  • kwargs – additional kwargs are passed to matplotlib.pyplot.figure() - e.g. figsize=(10,5)

Examples

Create a new figure and axes

>>> m = Maps()
>>> ...

Create a new figure and position the map at (left, bottom, width, height)

>>> m = Maps(ax=(.25, .5, .5, .5))

Use an existing figure and position the map at (left, bottom, width, height)

>>> import matplotlib.pyplot as plt
>>> from matplotlib.gridspec import GridSpec
>>> f = plt.figure()
>>> m = Maps(f=f, ax=(.25, .5, .5, .5))

Use a 3-digit integer to set the grid-position of the map (nrows, ncols, index)

>>> from matplotlib.gridspec import GridSpec
>>> m = Maps(ax=221)

Use a tuple of 3 integers to set the grid-position of the map (nrows, ncols, index)

>>> from matplotlib.gridspec import GridSpec
>>> m = Maps(ax=(2, 2, 1))

Put the map at a grid-position of an existing figure

>>> import matplotlib.pyplot as plt
>>> f = plt.figure()
>>> ax = f.add_subplot(211)
>>> m = Maps(f=f, ax=212)

Use a subplotspec to set the axis position

>>> from matplotlib.gridspec import GridSpec
>>> gs = GridSpec(2,2)
>>> m = Maps(ax=gs[0,0])

Use an existing axis to create the Maps-object (the associated figure is automatically detected)

>>> import matplotlib.pyplot as plt
>>> from eomaps import Maps
>>> f = plt.figure()
>>> ax = f.add_subplot(projection=Maps.CRS.Mollweide())
>>> m = Maps(ax=ax)

Use Maps-objects as context-manager to close the map and free memory once the map is exported.

>>> import matplotlib
>>> matplotlib.use("agg") # we can use a non-GUI backend since we only export png's
>>> from eomaps import Maps
>>> with Maps() as m:
>>>     m.add_feature.preset.coastline()
>>>     m.savefig(...)
CRS
Type

Accessor for available projections (Supercharged version of cartopy.crs)

CLASSIFIERS
Type

Accessor for available classifiers (provided by mapclassify)

_companion_widget_key
Type

Keyboard shortcut assigned to show/hide the companion-widget.