Skip to main content

Earth on AWS

Fused loads data from the Earth on AWS data catalog with the Python pystac_client library.

This UDF loads data from an endpoint by Element 84. It first searches for items in the cop-dem-glo-30 collection within the area specified by bbox then loads their data with odc.stac.load.

@fused.udf
def udf(bbox: fused.types.TileGDF):
import odc.stac
import pystac_client
from pystac.extensions.eo import EOExtension as eo

utils = fused.load(
"https://github.com/fusedio/udfs/tree/f928ee1/public/common/"
).utils

odc.stac.configure_s3_access(aws_unsigned=True)
catalog = pystac_client.Client.open("https://earth-search.aws.element84.com/v1")

items = catalog.search(
collections=["cop-dem-glo-30"],
bbox=bbox.total_bounds,
).item_collection()

resolution = int(20 * 2 ** (13 - bbox.z[0]))

ds = odc.stac.load(
items,
crs="EPSG:3857",
bands=["data"],
resolution=resolution,
bbox=bbox.total_bounds,
).astype(float)
arr = ds["data"].max(dim="time")
return utils.arr_to_plasma(arr.values, min_max=(0, 500), reverse=False)