Пример #1
0
    def __init__(self,
                 classifier,
                 data_feature,
                 cm_size_x=None,
                 cm_size_y=None,
                 cmask_feature='CLM',
                 cprobs_feature=None,
                 instance_id=None,
                 data_collection=None,
                 image_format=MimeType.TIFF_d32f,
                 model_evalscript=MODEL_EVALSCRIPT,
                 data_source=None):
        """ Constructor

        If both `cm_size_x` and `cm_size_y` are `None` and `data_feature` exists, cloud detection is computed at same
        resolution of `data_feature`.

        :param classifier: Cloud detector classifier. This object implements a `get_cloud_probability_map` and
            `get_cloud_masks` functions to generate probability maps and binary masks
        :param data_feature: Name of key in eopatch.data dictionary to be used as input to the classifier. If the
            `data_feature` does not exist, a new OGC request at the given cloud mask resolution is made
            with layer name set to `data_feature` parameter.
        :param cm_size_x: Resolution to be used for computation of cloud mask. Allowed values are number of column
            pixels (WMS-request) or spatial resolution (WCS-request, e.g. '10m'). Default is `None`
        :param cm_size_y: Resolution to be used for computation of cloud mask. Allowed values are number of row
            pixels (WMS-request) or spatial resolution (WCS-request, e.g. '10m'). Default is `None`
        :param cmask_feature: Name of key to be used for the cloud mask to add. The cloud binary mask is added to the
            `eopatch.mask` attribute dictionary. Default is `'clm'`.
        :param cprobs_feature: Name of key to be used for the cloud probability map to add. The cloud probability map is
            added to the `eopatch.data` attribute dictionary. Default is `None`, so no cloud probability map will
            be computed.
        :param instance_id: Instance ID to be used for OGC request. Default is `None`
        :param data_collection: Data collection to be requested by OGC service request.
        :param image_format: Image format to be requested by OGC service request. Default is `MimeType.TIFF_d32f`
        :param model_evalscript: CustomUrlParam defining the EVALSCRIPT to be used by OGC request. Should reflect the
            request necessary for the correct functioning of the classifier. For instance, for the
            `S2PixelCloudDetector` classifier, `MODEL_EVALSCRIPT` is used as it requests the required 10
            bands. Default is `MODEL_EVALSCRIPT`
        :param data_source: A deprecated alternative to data_collection
        :type data_source: DataCollection
        """
        warnings.warn(
            "AddCloudMaskTask is being deprecated. Please use AddMultiCloudMaskTask instead. "
            "See showcase at examples/mask/CloudMaskTask.ipynb",
            SHDeprecationWarning)

        data_collection = DataCollection(
            handle_deprecated_data_source(data_collection, data_source)
            or DataCollection.SENTINEL2_L1C)

        self.classifier = classifier
        self.data_feature = data_feature
        self.cm_feature = cmask_feature
        self.cm_size_x = cm_size_x
        self.cm_size_y = cm_size_y
        self.cprobs_feature = cprobs_feature
        self.instance_id = instance_id
        self.data_collection = data_collection
        self.image_format = image_format
        self.model_evalscript = model_evalscript
Пример #2
0
    def __init__(self,
                 layer,
                 feature=None,
                 valid_data_mask_feature='IS_DATA',
                 service_type=None,
                 data_collection=None,
                 size_x=None,
                 size_y=None,
                 maxcc=None,
                 image_format=MimeType.TIFF_d32f,
                 instance_id=None,
                 custom_url_params=None,
                 time_difference=None,
                 raise_download_errors=True,
                 data_source=None):
        # pylint: disable=too-many-arguments

        warnings.warn(
            "eo-learn is deprecating OGC services for the Processing API. "
            "Please use SentinelHubInputTask instead. See examples/io/ProcessingIO.ipynb for examples.",
            SHDeprecationWarning)

        data_collection = DataCollection(
            handle_deprecated_data_source(data_collection, data_source))

        self.layer = layer
        self.feature_type, self.feature_name = next(
            self._parse_features(layer if feature is None else feature,
                                 default_feature_type=FeatureType.DATA)())
        self.valid_data_mask_feature = self._parse_features(
            valid_data_mask_feature, default_feature_type=FeatureType.MASK)
        self.service_type = service_type
        self.data_collection = data_collection
        self.size_x = size_x
        self.size_y = size_y
        self.maxcc = maxcc
        self.image_format = image_format
        self.instance_id = instance_id

        if custom_url_params is None:
            custom_url_params = {}
        self.custom_url_params = {
            **{
                CustomUrlParam.SHOWLOGO: False,
                CustomUrlParam.TRANSPARENT: True
            },
            **custom_url_params
        }

        self.time_difference = time_difference
        self.raise_download_errors = raise_download_errors
Пример #3
0
    def __init__(self,
                 data_collection,
                 size=None,
                 resolution=None,
                 cache_folder=None,
                 config=None,
                 max_threads=None,
                 data_source=None):
        """
        :param data_collection: A collection of requested satellite data.
        :type data_collection: DataCollection
        :param size: Number of pixels in x and y dimension.
        :type size: tuple(int, int)
        :type resolution: Resolution in meters, passed as a single number or a tuple of two numbers -
            resolution in horizontal and resolution in vertical direction.
        :type resolution: float or (float, float)
        :param cache_folder: Path to cache_folder. If set to None (default) requests will not be cached.
        :type cache_folder: str
        :param config: An instance of SHConfig defining the service
        :type config: SHConfig or None
        :param max_threads: Maximum threads to be used when downloading data.
        :type max_threads: int
        :param data_source: A deprecated alternative to data_collection
        :type data_source: DataCollection
        """
        if (size is None) == (resolution is None):
            raise ValueError(
                "Exactly one of the parameters 'size' and 'resolution' should be given."
            )

        self.size = size
        self.resolution = resolution
        self.config = config or SHConfig()
        self.max_threads = max_threads
        self.data_collection = DataCollection(
            handle_deprecated_data_source(data_collection, data_source))
        self.cache_folder = cache_folder