How to use the sentinelhub.download.get_json function in sentinelhub

To help you get started, we’ve selected a few sentinelhub examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sentinel-hub / sentinelhub-py / sentinelhub / aws.py View on Github external
:param metafiles: List of additional metafiles available on AWS
                          (e.g. ``['metadata', 'tileInfo', 'preview/B01', 'TCI']``).
                          If parameter is set to `None` the list will be set automatically.
        :type metafiles: list(str) or None
        """
        self.product_id = product_id.split('.')[0]
        self.tile_list = self.parse_tile_list(tile_list)

        self.data_source = self.get_data_source()
        self.safe_type = self.get_safe_type()

        super().__init__(**kwargs)

        self.date = self.get_date()
        self.product_url = self.get_product_url()
        self.product_info = get_json(self.get_url(AwsConstants.PRODUCT_INFO))

        self.baseline = self.get_baseline()
github sentinel-hub / sentinelhub-py / sentinelhub / opensearch.py View on Github external
"""
    if bbox and bbox.crs is not CRS.WGS84:
        bbox = bbox.transform(CRS.WGS84)

    url_params = _prepare_url_params(tile_id, bbox, end_date, start_date, absolute_orbit)
    url_params['maxRecords'] = SHConfig().max_opensearch_records_per_query

    start_index = 1

    while True:
        url_params['index'] = start_index

        url = '{}search.json?{}'.format(SHConfig().opensearch_url, urlencode(url_params))
        LOGGER.debug("URL=%s", url)

        response = get_json(url)
        for tile_info in response["features"]:
            yield tile_info

        if len(response["features"]) < SHConfig().max_opensearch_records_per_query:
            break
        start_index += SHConfig().max_opensearch_records_per_query
github sentinel-hub / sentinelhub-py / sentinelhub / ogc.py View on Github external
params = {'SERVICE': ServiceType.WFS.value,
                  'REQUEST': 'GetFeature',
                  'TYPENAMES': DataSource.get_wfs_typename(self.data_source),
                  'BBOX': str(self.bbox.reverse()) if self.bbox.crs is CRS.WGS84 else str(self.bbox),
                  'OUTPUTFORMAT': MimeType.get_string(MimeType.JSON),
                  'SRSNAME': CRS.ogc_string(self.bbox.crs),
                  'TIME': '{}/{}'.format(self.time_interval[0], self.time_interval[1]),
                  'MAXCC': 100.0 * self.maxcc,
                  'MAXFEATURES': SHConfig().max_wfs_records_per_query,
                  'FEATURE_OFFSET': self.feature_offset}

        url = main_url + urlencode(params)

        LOGGER.debug("URL=%s", url)
        response = get_json(url)

        is_sentinel1 = self.data_source.is_sentinel1()
        for tile_info in response["features"]:
            if is_sentinel1:
                if self._sentinel1_product_check(tile_info['properties']['id'], self.data_source) and \
                        self.data_source.contains_orbit_direction(tile_info['properties']['orbitDirection']):
                    self.tile_list.append(tile_info)
            else:
                self.tile_list.append(tile_info)

        if len(response["features"]) < SHConfig().max_wfs_records_per_query:
            self.feature_offset = None
        else:
            self.feature_offset += SHConfig().max_wfs_records_per_query
github sentinel-hub / sentinelhub-py / sentinelhub / aws.py View on Github external
def get_tile_info(self):
        """
        Collects basic info about tile from tileInfo.json.

        :return: dictionary with tile information
        :rtype: dict
        """
        return get_json(self.get_url(AwsConstants.TILE_INFO))
github sentinel-hub / sentinelhub-py / sentinelhub / geopedia.py View on Github external
def _fetch_features(self):
        """ Retrieves a new page of features from Geopedia
        """
        if self.next_page_url is None:
            return

        response = get_json(self.next_page_url, post_values=self.query, headers=self.gpd_session.session_headers)

        self.features.extend(response['features'])
        self.next_page_url = response['pagination']['next']
        self.layer_size = response['pagination']['total']
github sentinel-hub / sentinelhub-py / sentinelhub / geopedia.py View on Github external
def _start_new_session(self):
        """ Starts a new session and calculates when the new session will end. If username and password are provided
        it will also make login.
        """
        self._session_start = datetime.datetime.now()

        session_id = self._parse_session_id(self._session_info) if self._session_info else ''
        session_url = '{}data/v1/session/create?locale=en&sid={}'.format(self.base_url, session_id)
        self._session_info = get_json(session_url)

        if self.username and self.password and self._parse_user_id(self._session_info) == self.UNAUTHENTICATED_USER_ID:
            self._make_login()

        if self.is_global:
            GeopediaSession._global_session_info = self._session_info
            GeopediaSession._global_session_start = self._session_start