Maxar Stereo Data#

This notebooks illustrates basic search and visualization of Maxar Stereo Imagery.

Coincident uses the Maxar ‘discovery’ STAC API to find high resolution stereo data.

import coincident
import geopandas as gpd
import matplotlib.pyplot as plt

%matplotlib inline
/home/docs/checkouts/readthedocs.org/user_builds/coincident/checkouts/104/src/coincident/io/download.py:27: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)
  from tqdm.autonotebook import tqdm

Load browse image#

Maxar provides monochrome uint8 or RGB browse images at ~30m resolution that we can visualize before ordering the full-resolution scenes.

# We first convert from geopandas metadata to a pystac items
items = coincident.search.to_pystac_items(gf_stereo)
da = coincident.io.xarray.open_maxar_browse(items[0]).squeeze()
da
<xarray.DataArray 'band_data' (y: 3848, x: 1005)> Size: 4MB
[3867240 values with dtype=uint8]
Coordinates:
    band         int64 8B 1
  * x            (x) float64 8kB -71.81 -71.81 -71.81 ... -71.53 -71.53 -71.53
  * y            (y) float64 31kB 43.06 43.06 43.06 43.06 ... 41.95 41.95 41.95
    spatial_ref  int64 8B ...
Attributes:
    AREA_OR_POINT:  Area
    scale_factor:   1.0
    add_offset:     0.0

Plot browse image#

For convenience you can create simplified figures directly without first loading the data with Xarray. Browse images are cloud-optimized-geotiffs with overviews for efficient previewing.

coincident.plot.plot_maxar_browse(items[0], overview_level=2);
../_images/a118dcff14ce71620c14017fd7ceadb6527e91efd3a5037b07bfa3c8ed34a78b.png

Load cloud-cover polygon#

For each acquisition, Maxar includes a Multipolygon that estimates cloud cover. Behind the scenes, coincident uses the stac-asset library to read and download assets of any STAC item. Because stac-asset uses asynchronous functions, you have to use await to return results.

bytes = await coincident.io.download.read_href(item, "cloud-cover")
gf_clouds = gpd.read_file(bytes)
gf_clouds.explore()
Make this Notebook Trusted to load map: File -> Trust Notebook

Download browse image + metadata#

coincident wraps the stac-asset library to easily download local copies of a STAC item and all of its assets (e.g. metadata and cloud cover mask)

# Set download directory to match item STAC ID
download_dir = f"/tmp/{item.id}"
local_item = await coincident.io.download.download_item(item, download_dir)
/home/docs/checkouts/readthedocs.org/user_builds/coincident/checkouts/104/.pixi/envs/dev/lib/python3.12/site-packages/stac_asset/http_client.py:177: UserWarning: the actual content type does not match the expected: actual=application/json, expected=application/geo+json
  warnings.warn(str(err))
!ls {download_dir}
104001006724D500.browse.tif  104001006724D500.json
104001006724D500.cloud.json  104001006724D500.sample-points.json