Mapping

Map data onto a geographic map!

geographic keywords

For geographic annotations, there are these keywords:

ahlive keyword

type

scope

description

crs

str

subplot

the data’s projection coordinate reference system (crs)

projection

str

subplot

the desired output crs

central_lon

float

subplot

the desired longitude in degrees to center on

borders

bool

subplot

whether to show country borders

coastline

bool

subplot

whether to show coastlines

tiles

bool

subplot

whether to show tiles

zoom

int

subplot

zoom level of tiles

land

bool

subplot

whether to show land

ocean

bool

subplot

whether to show ocean

lakes

bool

subplot

whether to show lakes

rivers

bool

subplot

whether to show rivers

states

bool

subplot

whether to show US states’ borders

worldwide

bool

subplot

whether to set to global extents

reference crs

To utilize any geographic annotations, pass crs OR projection as an instantiated cartopy.crs object the class name.

crs specifies the data’s coordinate reference system; it’s often set to ccrs.PlateCarree(), or conveniently 'platecarree', if the data is in degrees.

[1]:
import xarray as xr
import ahlive as ah
ds = xr.tutorial.open_dataset('air_temperature').isel(time=slice(0, 3))
ah_ds = ah.Dataset(ds, 'lon', 'lat', 'air', crs='platecarree')
ah_ds.render()
[########################################] | 100% Completed |  7.6s
[1]:

projection crs

projection on the other hand specifies the desired output crs. If crs is not specified, but projection is set, crs defaults to ccrs.PlateCarree().

[2]:
import xarray as xr
import ahlive as ah
ds = xr.tutorial.open_dataset('air_temperature').isel(time=slice(0, 3))
ah_ds = ah.Dataset(ds, 'lon', 'lat', 'air', projection='lambertconformal')
ah_ds.render()
[########################################] | 100% Completed | 11.5s
[2]:
[3]:
import xarray as xr
import ahlive as ah
import cartopy.crs as ccrs
import cartopy.feature as cfeature

ds = xr.tutorial.open_dataset("air_temperature").isel(time=slice(0, 3))
ah_ds = ah.Dataset(
    ds,
    "lon",
    "lat",
    "air",
    projection=ccrs.Orthographic(central_latitude=25, central_longitude=-88),
    coastline=cfeature.COASTLINE.with_scale("50m"),
)
ah_ds.render()
/home/docs/checkouts/readthedocs.org/user_builds/ahlive/conda/main/lib/python3.9/site-packages/cartopy/io/__init__.py:241: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/50m_physical/ne_50m_coastline.zip
  warnings.warn(f'Downloading: {url}', DownloadWarning)
[########################################] | 100% Completed | 15.1s
[3]: