new_inset_map

Maps.new_inset_map(xy=(45, 45), xy_crs=4326, radius=5, radius_crs=None, plot_position=(0.5, 0.5), plot_size=0.5, inset_crs=4326, layer=None, boundary=True, background_color='w', shape='ellipses', indicate_extent=True, indicator_line=False)

Create a new (empty) inset-map that shows a zoomed-in view on a given extent.

The returned Maps-object can then be used to populate the inset-map with features, datasets etc.

See examples below on how to use inset-maps.

Note

  • By default NO features are added to the inset-map! Use it just like any other Maps-object to add features or plot datasets!

  • Zooming is disabled on inset-maps for now due to issues with zoom-events on overlapping axes.

  • Non-rectangular cropping of WebMap services is not yet supported. (e.g. use “rectangles” as shape and the native CRS of the WebMap service for the inset map.)

Parameters:
  • xy (tuple, optional) – The center-coordinates of the area to indicate. (provided in the xy_crs projection) The default is (45., 45.).

  • xy_crs (any, optional) – The crs used for specifying the center position of the inset-map. (can be any crs definition supported by PyProj) The default is 4326 (e.g. lon/lat).

  • radius (float or tuple, optional) – The radius of the extent to indicate. (provided in units of the radius_crs projection) The default is 5.

  • radius_crs (None or a crs-definition, optional) –

    The crs used for specifying the radius. (can be any crs definition supported by PyProj)

    • If None: The crs provided as “xy_crs” is used

    • If shape == “geod_circles”, “radius_crs” must be None since the radius of a geodesic circle is defined in meters!

    The default is None.

  • plot_position (tuple, optional) – The center-position of the inset map in relative units (0-1) with respect to the figure size. The default is (.5,.5).

  • plot_size (float, optional) – The relative size of the inset-map compared to the figure width. The default is 0.5.

  • inset_crs (any, optional) – The crs that is used in the inset-map. The default is 4326.

  • layer (str or None, optional) – The layer associated with the inset-map. If None (the default), the layer of the Maps-object used to create the inset-map is used.

  • boundary (bool, str or dict, optional) –

    • If True: indicate the boundary of the inset-map with default colors (e.g.: {“ec”:”r”, “lw”:2})

    • If False: don’t add edgecolors to the boundary of the inset-map

    • If a string is provided, it is identified as the edge-color of the boundary (e.g. any named matplotlib color like “r”, “g”, “darkblue”…)

    • if dict: use the provided values for “ec” (e.g. edgecolor) and “lw” (e.g. linewidth)

    The default is True.

  • background_color (str, tuple or None) –

    The background color to use.

    • if str: a matplotlib color identifier (e.g. “r”, “#162347”)

    • if tuple: a RGB or RGBA tuple (values must be in the range 0-1)

    • If None, no background patch will be drawn (e.g. transparent)

    The default is “w” (e.g. white)

  • shape (str, optional) – The shape to use. Can be either “ellipses”, “rectangles” or “geod_circles”. The default is “ellipses”.

  • indicate_extent (bool or dict, optional) –

    • If True: add a polygon representing the inset-extent to the parent map.

    • If a dict is provided, it will be used to update the appearance of the added polygon (e.g. facecolor, edgecolor, linewidth etc.)

    NOTE: you can also use m_inset.add_extent_indicator(…) to manually indicate the inset-shape on arbitrary Maps-objects.

    The default is True.

  • indicator_line (bool or dict, optional) –

    • If True: add a line that connects the inset-map to the indicated extent on the parent map

    • If a dict is provided, it is used to update the appearance of the line (e.g. c=”r”, lw=2, …)

    NOTE: you can also use m_inset.add_indicator_line(…) to manually indicate the inset-shape on arbitrary Maps-objects.

    The default is False.

Returns:

m – A InsetMaps-object of the inset-map. (you can use it just like any other Maps-object!)

Return type:

eomaps.inset_maps.InsetMaps

See also

Maps.add_extent_indicator

Indicate inset-extent on another map (as polygon).

Maps.set_inset_position

Set the (center) position and size of the inset-map.

Examples

Simple example:

>>> m = Maps()
>>> m.add_feature.preset.coastline()
>>> m2 = m.new_inset_map(xy=(45, 45), radius=10,
>>>                      plot_position=(.3, .5), plot_size=.7)
>>> m2.add_feature.preset.ocean()

… a bit more complexity:

>>> m = Maps(Maps.CRS.Orthographic())
>>> m.add_feature.preset.coastline() # add some coastlines
>>> m2 = m.new_inset_map(xy=(5, 45),
>>>                      xy_crs=4326,
>>>                      shape="geod_circles",
>>>                      radius=1000000,
>>>                      plot_position=(.3, .4),
>>>                      plot_size=.5,
>>>                      inset_crs=3035,
>>>                      edgecolor="g",
>>>                      indicate_extent=False)
>>>
>>> m2.add_feature.preset.coastline()
>>> m2.add_feature.preset.ocean()
>>> m2.add_feature.preset.land()
>>> m2.set_data([1, 2, 3], [5, 6, 7], [45, 46, 47], crs=4326)
>>> m2.plot_map()
>>> m2.add_annotation(ID=1)
>>> m2.add_extent_indicator(m, ec="g", fc=(0,1,0,.25))

Multi-layer inset-maps:

>>> m = Maps(layer="first")
>>> m.add_feature.preset.coastline()
>>> m3 = m.new_layer("second")
>>> m3.add_feature.preset.ocean()
>>> # create an inset-map on the "first" layer
>>> m2 = m.new_inset_map(layer="first")
>>> m2.add_feature.preset.coastline()
>>> # create a new layer of the inset-map that will be
>>> # visible if the "second" layer is visible
>>> m3 = m2.new_layer(layer="second")
>>> m3.add_feature.preset.coastline()
>>> m3.add_feature.preset.land()
>>> m.util.layer_selector()