G-LiHT#

This notebook illustrates search, directly loading DEMs, and downloading DEMs and LPCs for local processing

Dataset

Alias

Type

Start

End

Extent

Source

NASA G-LiHT

gliht

LiDAR

2011-07-28

2020-03-12

US Territories

NASA G-LiHT

import coincident
import geopandas as gpd
from shapely.geometry import box
import matplotlib.pyplot as plt
# %config InlineBackend.figure_format = 'retina'
/home/docs/checkouts/readthedocs.org/user_builds/coincident/checkouts/v0.5/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

Get Data#

NASA G-LiHT has many different provided gridded datasets. The following collections below are the current datasets supported by coincident.

Collection

Description

GLORTHO_001

orthorectified high-resolution aerial photography

GLCHMT_001

maximum canopy height and canopy variability information

GLDSMT_001

Digital Surface Model, Mean, Aspect, Rugosity, and Slope

GLDTMT_001

bare earth elevation, aspect and slope on the EGM96 Geoid

GLLIDARPC_001

LiDAR Point Cloud data product (LAS format)

Note

Not all G-LiHT flights will contain every single product listed. For example, a flight may have ‘dsm’ data but not ‘ortho’ data.

# Subset a particular scene
collection = "GLDTMT_001"
gf_gliht = gf.query(f'collection == "{collection}"')
gf_gliht.id
10    GLDTMT_SERC_CalTarps_31July2017_am_l9s0_DTM
11    GLDTMT_SERC_CalTarps_31July2017_am_l8s0_DTM
12    GLDTMT_SERC_CalTarps_31July2017_am_l6s0_DTM
13    GLDTMT_SERC_CalTarps_31July2017_am_l2s0_DTM
14    GLDTMT_SERC_CalTarps_31July2017_am_l7s0_DTM
15    GLDTMT_SERC_CalTarps_31July2017_am_l3s0_DTM
16    GLDTMT_SERC_CalTarps_31July2017_am_l1s0_DTM
17    GLDTMT_SERC_CalTarps_31July2017_am_l5s0_DTM
18    GLDTMT_SERC_CalTarps_31July2017_am_l4s0_DTM
19    GLDTMT_SERC_CalTarps_31July2017_am_l0s0_DTM
41        GLDTMT_SERC_ForestGEO_31July2017_am_DTM
Name: id, dtype: object
# Just use the first one
gs_item = gf_gliht.iloc[0]
c = gs_item.geometry.centroid
mini_aoi = gpd.GeoDataFrame(
    geometry=[box(c.x - 0.0045, c.y - 0.0045, c.x + 0.0045, c.y + 0.0045)],
    crs="EPSG:4326",
)
m = gf_gliht.explore(column="id")
mini_aoi.explore(m=m, color="red", style_kwds={"fill": False, "weight": 3})
Make this Notebook Trusted to load map: File -> Trust Notebook

Stream#

First we’ll show how to stream a subset of a gridded DSM directly into Xarray

Important

Unlike the G-LiHT search, you will need NASA Earthdata credentials (aka EarthData Login (EDL)) to read in and download the gridded datasets from G-LiHT. This requires creating an EDL Token and making sure you’ve set the environment variable EARTHDATA_TOKEN=xxxxx

%%time

da = coincident.io.xarray.load_gliht(
    item=gs_item,
    aoi=mini_aoi,
)
da
CPU times: user 19.6 ms, sys: 9.35 ms, total: 28.9 ms
Wall time: 4.38 s
<xarray.DataArray (time: 1, y: 1013, x: 650)> Size: 3MB
[658450 values with dtype=float32]
Coordinates:
    time         object 8B 2017-07-31T04:00:00+00:00
  * y            (y) float64 8kB 4.307e+06 4.307e+06 ... 4.306e+06 4.306e+06
  * x            (x) float64 5kB 3.654e+05 3.654e+05 ... 3.66e+05 3.66e+05
    spatial_ref  int64 8B 0
Attributes:
    TIFFTAG_XRESOLUTION:  1
    TIFFTAG_YRESOLUTION:  1
    AREA_OR_POINT:        Area
    scale_factor:         1.0
    add_offset:           0.0
coincident.plot.plot_dem(da)
plt.title(gs_item.id);
../_images/09e8b79f18e14c1ea327a891b727e4c1ee4659f5a8015cd50cd420b3f4fd7af4.png

Download#

Download multiple STAC Item Assets#

This will put STAC metadata, extended metadata, a browse/thumbnail image, and a TIF in a specified folder

# back to a GeoDataFrame from a Series
gfi = gpd.GeoDataFrame([gs_item])

# And to a Pystac Item
items = coincident.search.to_pystac_items(gfi)
items[0]
<Item id=GLDTMT_SERC_CalTarps_31July2017_am_l9s0_DTM>
# Download the item assets (browse, metadata, thumbnail)
local_item = await coincident.io.download.download_item(
    items[0],
    path="/tmp/gliht/",
)
/home/docs/checkouts/readthedocs.org/user_builds/coincident/checkouts/v0.5/.pixi/envs/docs/lib/python3.14/site-packages/stac_asset/http_client.py:179: UserWarning: the actual content type does not match the expected: actual=application/echo10+xml, expected=application/xml
  warnings.warn(str(err))

Download a single file#

tif_key = [x for x in gs_item.assets.keys() if x.startswith("001")][0]
href = gs_item.assets[tif_key]["href"]
coincident.io.download.download_files([href], "/tmp/")
['/tmp/GLDTMT_SERC_CalTarps_31July2017_am_l9s0_DTM.tif']