revrt.costs.masks.Masks#

class Masks(shape, crs, transform, masks_dir='.')[source]#

Bases: object

Create, load, and store mask data layers

Parameters:
  • shape (tuple) – Shape of mask rasters (height, width).

  • crs (str | dict) – Coordinate reference system of mask rasters.

  • transform (affine.Affine) – Affine transform of mask rasters.

  • masks_dir (path-like, optional) – Directory for storing/finding mask GeoTIFFs. By default, ".".

Methods

create(land_mask_shp_fp[, save_tiff, ...])

Create mask layers from a polygon land vector file

load(layer_fp)

Load the mask layers from GeoTIFFs

Attributes

LANDFALL_MASK_FNAME

One pixel width line at shore

LAND_MASK_FNAME

Raw mask - landfall mask

OFFSHORE_MASK_FNAME

Offshore mask filename

RAW_LAND_MASK_FNAME

Rasterized land vector

dry_mask

Dry cells boolean mask; no landfall cells

dry_plus_mask

Dry cells boolean mask; with landfall cells

landfall_mask

Landfalls cells boolean mask; one cell wide

wet_mask

Wet cells boolean mask; no landfall cells

wet_plus_mask

Wet cells mask, with landfall cells

LANDFALL_MASK_FNAME = 'landfall_mask.tif'#

One pixel width line at shore

RAW_LAND_MASK_FNAME = 'raw_land_mask.tif'#

Rasterized land vector

LAND_MASK_FNAME = 'land_mask.tif'#

Raw mask - landfall mask

OFFSHORE_MASK_FNAME = 'offshore_mask.tif'#

Offshore mask filename

property landfall_mask#

Landfalls cells boolean mask; one cell wide

Type:

array-like

property wet_mask#

Wet cells boolean mask; no landfall cells

Type:

array-like

property dry_mask#

Dry cells boolean mask; no landfall cells

Type:

array-like

property dry_plus_mask#

Dry cells boolean mask; with landfall cells

Type:

array-like

property wet_plus_mask#

Wet cells mask, with landfall cells

Type:

array-like

create(land_mask_shp_fp, save_tiff=True, reproject_vector=True, lock=None)[source]#

Create mask layers from a polygon land vector file

Parameters:
  • land_mask_shp_fp (str) – Full path to land polygon GPKG or shp file

  • save_tiff (bool, optional) – Save mask as tiff if true. By default, True.

  • reproject_vector (bool, optional) – Reproject CRS of vector to match template raster if True. By default, True.

  • lock (bool | `dask.distributed.Lock`, optional) – Lock to use to write data using dask. If not supplied, a single process is used for writing data to the mask GeoTIFFs. By default, None.

load(layer_fp)[source]#

Load the mask layers from GeoTIFFs

Parameters:
  • layer_fp (path-like) – Path to LayeredFile on disk for which masks were created. The masks will be of the same shape/crs/transform as this file.

  • This does not need to be called if :meth:`Masks.create()`

  • was run previously. Mask files must be in the current directory.