How to use the descarteslabs.common.dotdict.DotDict function in descarteslabs

To help you get started, we’ve selected a few descarteslabs 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 descarteslabs / descarteslabs-python / descarteslabs / client / services / metadata / metadata.py View on Github external
kwargs["sort_order"] = sort_order

        if randomize is not None:
            kwargs["random_seed"] = randomize

        if continuation_token is not None:
            kwargs["continuation_token"] = continuation_token

        r = self.session.post("/search", json=kwargs)

        fc = {"type": "FeatureCollection", "features": r.json()}

        if "x-continuation-token" in r.headers:
            fc["properties"] = {"continuation_token": r.headers["x-continuation-token"]}

        return DotDict(fc)
github descarteslabs / descarteslabs-python / descarteslabs / client / services / raster / raster.py View on Github external
if can_blosc:
            metadata = json.loads(r.raw.readline().decode("utf-8").strip())
            array_meta = json.loads(r.raw.readline().decode("utf-8").strip())
            array = read_blosc_array(array_meta, r.raw)
        else:
            npz = np.load(BytesIO(r.content))
            array = npz["data"]
            metadata = json.loads(npz["metadata"].tostring().decode("utf-8"))

        if len(array.shape) > 2:
            if order == "image":
                return array.transpose((1, 2, 0)), metadata
            elif order == "gdal":
                return array, metadata
        else:
            return array, DotDict(metadata)
github descarteslabs / descarteslabs-python / descarteslabs / client / services / metadata / metadata.py View on Github external
def get_bands_by_product(self, product_id):
        """
        All bands (includig derived bands) available in a product.

        :param str product_id: A product identifier.

        :return: A dictionary mapping band ids to dictionaries of their metadata.
            Returns empty dict if product id not found.
        :rtype: DotDict
        """
        r = self.session.get("/bands/all/{}".format(product_id))

        return DotDict(r.json())
github descarteslabs / descarteslabs-python / descarteslabs / client / services / metadata / metadata.py View on Github external
if fill_fraction is not None:
            kwargs["fill_fraction"] = fill_fraction

        if q is not None:
            if not isinstance(q, list):
                q = [q]
            kwargs["query_expr"] = AndExpression(q).serialize()

        if pixels:
            kwargs["pixels"] = pixels

        if storage_state:
            kwargs["storage_state"] = storage_state

        r = self.session.post("/summary", json=kwargs)
        return DotDict(r.json())
github descarteslabs / descarteslabs-python / descarteslabs / client / services / places / places.py View on Github external
Example::
            >>> from descarteslabs.client.services import Places
            >>> il_counties = Places().prefix('north-america_united-states_illinois', placetype='county')
            >>> len(il_counties['features'])
            102

        """
        params = {}

        if placetype:
            params["placetype"] = placetype
        params["geom"] = geom
        r = self.session.get("/prefix/%s.%s" % (slug, output), params=params)

        return DotDict(r.json())
github descarteslabs / descarteslabs-python / descarteslabs / client / services / raster / raster.py View on Github external
'type': 'Feature'
            }
        """
        shape = shapely_to_geojson(shape)
        shape = as_json_string(shape)
        params = {
            "resolution": resolution,
            "tilesize": tilesize,
            "pad": pad,
            "shape": shape,
            "maxtiles": maxtiles,
        }

        while True:
            r = self.session.post("/dlkeys/from_shape", json=params)
            fc = DotDict(r.json())
            for t in fc.features:
                yield t
            iterstate = fc.get("iterstate", None)
            if iterstate:
                params["start_zone"] = iterstate.start_zone
                params["start_ti"] = iterstate.start_ti
                params["start_tj"] = iterstate.start_tj
            else:
                break
github descarteslabs / descarteslabs-python / descarteslabs / client / services / tasks / tasks.py View on Github external
"""
        params = {"limit": limit}
        for field in [
            "status",
            "created",
            "updated",
            "sort_field",
            "sort_order",
            "include",
            "continuation_token",
        ]:
            if locals()[field] is not None:
                params[field] = locals()[field]
        r = self.session.get("/groups", params=params)
        r.raise_for_status()
        return DotDict(r.json())
github descarteslabs / descarteslabs-python / descarteslabs / client / services / vector / vector.py View on Github external
if available.

        :raises ~descarteslabs.client.exceptions.NotFoundError: Raised if
            subsequent pages cannot be found.
        :raises ~descarteslabs.client.exceptions.RateLimitError: Raised when
            too many requests have been made within a given time period.
        :raises ~descarteslabs.client.exceptions.ServerError: Raised when
            a unknown error occurred on the server.
        """
        params = dict(limit=page_size, page=page)

        # override the json api content type which is default.
        r = self.session.get(
            "/products", params=params, headers={"Content-Type": "application/json"}
        )
        return DotDict(r.json())