geodata.Mask.merge_layer
========================

.. py:method:: geodata.Mask.merge_layer(method: MergingMethods = 'and', weights: Optional[dict[str, float]] = None, layers: Optional[Iterable[str]] = None, trim: bool = False, show_raster: bool = True, reference_layer: Optional[str] = None, attribute_save: bool = True, **kwargs) -> rasterio.DatasetReader

   Merge multiple and flatten multiple layers from self.layers using either 'and'
   and 'sum' method. By default, 'and' method is used, and we would save the result
   to `merged_mask` attribute.

   Adjusted from rasterio's documentation on merging:
   https://rasterio.readthedocs.io/en/latest/api/rasterio.merge.html

   Geospatial bounds and resolution of a new output file in the units of the input
   file coordinate reference system may be provided, but by default, the method will
   use the layer with the best resolution for the output bounds/resolution, unless a
   reference layer is provided.

   :param method: The method to merge the layers. By default, 'and' method is used.
                  'and' method will perform "AND" operation over the overlapping pixels.
                  'sum' method will take the sum of the overlapping pixels.
   :type method: str
   :param weights: The weight of each layer to be merged. By default, all layers
                   will have the same weight of 1.
   :type weights: dict
   :param layers: The list of layers to be merged. If not specified, all layers
                  in the object will be merged.
   :type layers: Iterable[str]
   :param trim: Whether the method will trim the all-empty row/column border
                of the raster. By default, this is set to `False`.
   :type trim: bool
   :param show_raster: Whether the method will plot the merged raster. By default,
                       this is set to `True`.
   :type show_raster: bool
   :param reference_layer: The name of the layer to be used as the reference layer.
                           If not specified, the method will use the layer with the best (highest) resolution.
   :type reference_layer: str
   :param attribute_save: Whether the method will save the merged raster to the
                          `merged_mask` attribute. By default, this is set to `True`.
   :type attribute_save: bool
   :param \*\*kwargs: Additional arguments passed to the `rasterio.merge` method.

   :returns: The merged raster.
   :rtype: rasterio.DatasetReader

   :raises ValueError: If the specified method is other than 'and' and 'sum'.

