lair.geo.add_locator_map#

lair.geo.add_locator_map(ax, main_extent, main_extent_crs, locator_extent=(-125, -105, 30, 50), bounds=(0.7, 0.7, 0.29, 0.29), locator_crs=None, color='red', linewidth=2, zorder=8, scale='50m', fill=False)[source]#

Add a small locator map inside a map that shows where the main map is.

The locator map is an inset of ax, placed by bounds as a fraction of the main axes. It shows land, ocean and state boundaries (Natural Earth, 1:50 million by default) and the extent of the main map as an outline, or filled with fill=True. The defaults put a map of the western United States in the upper right corner.

Parameters:
  • ax (cartopy.mpl.geoaxes.GeoAxes) – The main map’s axes, to add the locator map to

  • main_extent (list[float]) – Extent of the main map, [minx, maxx, miny, maxy], in main_extent_crs

  • main_extent_crs (ccrs.CRS) – CRS of the main extent

  • locator_extent (list[float], optional) – Extent of the locator map, [west, east, south, north] in degrees of longitude and latitude, by default the western United States, (-125, -105, 30, 50)

  • bounds (tuple[left, bottom, width, height], optional) – Position of the locator map as fractions (0 to 1) of ax, as for Axes.inset_axes, by default the upper right corner, (0.7, 0.7, 0.29, 0.29)

  • locator_crs (ccrs.Projection, optional) – Projection of the locator map, by default an Albers equal-area projection centered at 111 degrees west

  • color (str, optional) – Color of the main-extent box drawn on the locator map (its outline, and its fill when fill=True), by default "red"

  • linewidth (float, optional) – Line width of the main-extent outline, by default 2

  • zorder (int, optional) – Zorder of the locator map, by default 8, above the main map’s layers

  • scale (str, optional) – Natural Earth scale of the ocean, land and state features: "10m", "50m" or "110m" (1:10, 1:50 and 1:110 million), by default "50m". A coarser scale is smaller to download and faster to draw.

  • fill (bool, optional) – Fill the main-extent box with color, by default False (outline only)

Returns:

cartopy.mpl.geoaxes.GeoAxes – Axes object of the locator map

Return type:

GeoAxes

See also

plot_grid

Draws a grid’s cells on the main map.

add_latlon_ticks

Labels the main map’s ticks in degrees.

Notes

Cartopy downloads the Natural Earth features the first time it draws them (the internet is needed), and caches them.

Examples

A locator map of the western United States in the upper right corner of ax, with the main map’s extent outlined in red (Draw a map of an inventory draws one):

main_extent = [-112.2, -111.5, 40.4, 41.0]
add_locator_map(ax, main_extent, PC)

A locator map of Utah and its neighbors in the upper left corner:

add_locator_map(
    ax,
    main_extent,
    PC,
    locator_extent=[-117, -106, 35, 43],
    bounds=(0.02, 0.7, 0.29, 0.29),
    locator_crs=PC,
)

The main map’s extent as a filled red box, on the coarser 110 million scale:

add_locator_map(ax, main_extent, PC, fill=True, scale="110m")