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='all', boundary=True, shape='ellipses', indicate_extent=True, **kwargs)
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, optional) – The layer associated with the inset-map. Note: If you specify a dedicated layer for the inset-map, the contents of the inset-map will only be visible on that specific layer! To create different views of an inset-map for different layers, simply create a child-layer from the inset-map (see examples below). By default the “all” layer is used so that the contents of the inset-map are visible independent of the currently visible layer. The default is “all”.
boundary (bool 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 dict: use the provided values for “ec” (e.g. edgecolor) and “lw” (e.g. linewidth)
The default is True.
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.indicate_inset_extent(…) to manually indicate the inset-shape on arbitrary Maps-objects.
- Returns
m – A eomaps.Maps-object of the inset-map. (use it just like any other Maps-object)
- Return type
See also
The
m.indicate_inset_extent
Plot a polygon representing the extent of the inset map on another Maps object.
m.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.indicate_inset_extent(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()