xarray.Dataset.spatial.generate_land_sea_mask

xarray.Dataset.spatial.generate_land_sea_mask#

Dataset.spatial.generate_land_sea_mask(data_var=None, method='regionmask', **options)#

Generate a land-sea mask.

Parameters:
  • data_var (str, optional) – Name of the variable whose lat/lon coordinates will be used to generate the land/sea mask. If omitted then a mask variable will be generated using the lat/lon coordinates in the dataset.

  • method (str, optional) – The method to use for generating the mask, by default “regionmask”. Supported methods: “regionmask”, “pcmdi”.

  • **options (Any) – These options are passed directly to the method. See specific method documentation for available options: xcdat.mask.pcmdi_land_sea_mask() for PCMDI options

Returns:

xr.DataArray – The land/sea mask.

Examples

Generate a mask using the default method (regionmask):

>>> mask = ds.spatial.generate_land_sea_mask("tas")

Generate a mask using the “pcmdi” method:

>>> mask = ds.spatial.generate_land_sea_mask("tas", method="pcmdi")

Generate a mask using the “pcmdi” method, with customization:

>>> mask = ds.spatial.generate_land_sea_mask("tas", method="pcmdi", source=high_res_ds, source_data_var="highres")

Generating a mask from a new grid:

>>> grid = xc.create_uniform_grid(-90, 90, 1, 0, 359, 1)
>>> mask = grid.spatial.generate_land_sea_mask()