geodata.mask.Mask#
- class geodata.mask.Mask(name: str, layer_path: str | list | dict | None = None, layer_name: str | list | None = None, mask_dir: str = MASK_DIR, **kwargs)#
A class to create, manipulate, and load geodata mask object that takes GeoTIFF or shp files as input.
Creating a new mask object. Layer_path will take the file name(s) without extension as the default layer name. If layer name(s) is/are specified, it will take the corresponding layer_name(s) as the name for new layer(s). Layer path can also be a dictionary of {layer_name: layer_path(str)} key-value pairs.
- Parameters:
name (str) – Name for the new mask object.
layer_path (str or dict) – Path(s) of new layers to beadded to the mask object. It can be None. In that case, nothing will be added.
layer_name (str or list) – Names for the incoming layers. If layer_path is a dictionary, layer_name will be ignored.
mask_dir (str) – The path to where the mask object would be saved/stored. By default, it should be the MASK_PATH constant in config.py.
**kwargs – Additional arguments passed to the add_layer method, only used if layers need to be added.
- MergingMethods#
- name#
- merged_mask = None#
- shape_mask#
- saved = False#
- mask_dir#
Methods#
|
Add a layer to the mask from given path(s) by calling the _add_layer() method. |
|
Remove a layer in the mask given layer name. |
|
Rename a layer in the mask given name. |
|
Get resolutions of layers. |
|
Get boundary information of layers |
|
Find the bounding box that's within specified layers. |
|
Crop a layer of mask object using crop_raster method. |
|
Trim a layer of mask object using trim_raster method. |
|
Filter a layer of mask object using filter_raster method. |
|
Merge multiple and flatten multiple layers from self.layers using either 'and' |
Remove the saved merged mask. |
|
|
Add shapes to the mask layers. This is different from shape extractions, |
|
Extract the shapes on the (by default) merged_mask layer, and save the result |
|
Remove a shape from shape_mask dictionary |
|
Using xarray to load the merged_layer masks. |
|
Using xarray to load the shape masks. |
Close all the opened rasters. This method will disable further save_mask() call. |
|
|
Save a mask object to the directory. By default, the directory should be the |
|
Load a previously saved mask object by name. |