๐Ÿ”ฌ Inset Maps๏ƒ

How to create inset maps๏ƒ

Inset maps are used to show zoomed-in regions of a map and can be created with Maps.new_inset_map().

from eomaps import Maps
m = Maps()                                      # the "parent" Maps-object (e.g. the "big" map)
m.add_feature.preset.coastline()
m_i = m.new_inset_map(xy=(125, 40), radius=10)  # a new Maps-object that represents the inset-map
m_i.add_feature.preset.ocean()                  # it can be used just like any other Maps-objects!
m_i.add_indicator_line()
  • An inset-map is defined by itโ€™s center-position and a radius

  • The used boundary-shape can be one of:

    • โ€œellipsesโ€ (e.g. projected ellipses with a radius defined in a given crs)

    • โ€œrectanglesโ€ (e.g. projected rectangles with a radius defined in a given crs)

    • โ€œgeod_circlesโ€ (e.g. geodesic circles with a radius defined in meters)

For convenience, inset-map objects have the following special methods defined:

InsetMaps.set_inset_position

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

InsetMaps.add_extent_indicator

Add a polygon to a map that indicates the current extent of this inset-map.

InsetMaps.add_indicator_line

Add a line that connects the inset-map to the inset location on a given map.

Checkout the associated example on how to use inset-maps: Inset-maps - get a zoomed-in view on selected areas

To quickly re-position (and re-size) inset-maps, have a look at the ๐Ÿ—๏ธ Layout Editor!

from eomaps import Maps
m = Maps(Maps.CRS.PlateCarree(central_longitude=-60))
m.add_feature.preset.ocean()

m_i = m.new_inset_map(xy=(5, 45), radius=10,
                      plot_position=(.3, .5), plot_size=.7,
                      boundary=dict(ec="r", lw=4),
                      indicate_extent=dict(fc=(1,0,0,.5),
                                           ec="r", lw=1)
                      )
m_i.add_indicator_line(m, c="r")

m_i.add_feature.preset.coastline()
m_i.add_feature.preset.countries()
m_i.add_feature.preset.ocean()
m_i.add_feature.cultural.urban_areas(fc="r", scale=10)
m_i.add_feature.physical.rivers_europe(ec="b", lw=0.25,
                                       fc="none", scale=10)
m_i.add_feature.physical.lakes_europe(fc="b", scale=10)
_images/inset_maps.png

new_inset_map

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

Zoomed in views on datasets๏ƒ

To simplify the creation of โ€œzoomed-inโ€ views on datasets, both the data and the classification of the data must be the same.

For this purpose, EOmaps provides 2 convenience-functions:

from eomaps import Maps
import numpy as np

x, y = np.meshgrid(np.linspace(-20, 20, 50), np.linspace(-50, 60, 100))
data = x + y

m = Maps(ax=131)
m.set_data(data, x, y)
m.set_shape.raster()
m.set_classify.Quantiles(k=10)
m.plot_map(cmap="tab10", vmin=-10, vmax=40)

# Create a new inset-map that shows a zoomed-in view on a given dataset
m_inset = m.new_inset_map(xy=(5, 20), radius=8, plot_position=(0.75, .5))

# inherit both the data and the classification specs from "m"
m_inset.inherit_data(m)
m_inset.inherit_classification(m)

m_inset.set_shape.rectangles()
m_inset.plot_map(ec="k", lw=0.25)