revrt.costs.masks.Masks#
- class Masks(shape, crs, transform, masks_dir='.')[source]#
Bases:
object
Create, load, and store mask data layers
- Parameters:
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
One pixel width line at shore
Raw mask - landfall mask
Offshore mask filename
Rasterized land vector
Dry cells boolean mask; no landfall cells
Dry cells boolean mask; with landfall cells
Landfalls cells boolean mask; one cell wide
Wet cells boolean mask; no landfall cells
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 filesave_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.