Skip to content

Instantly share code, notes, and snippets.

@kapadia
Created February 1, 2023 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kapadia/8c25ff4f6659feda1105ae5e2e6dd7cc to your computer and use it in GitHub Desktop.
Save kapadia/8c25ff4f6659feda1105ae5e2e6dd7cc to your computer and use it in GitHub Desktop.
Interface with LP DAAC using Earthdata token
import os
import rasterio as rio
url = "https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSS30.020/HLS.S30.T22KDF.2023030T133831.v2.0/HLS.S30.T22KDF.2023030T133831.v2.0.B05.tif"
token = os.environ.get("NASA_EARTHDATA_TOKEN")
gdal_env = {
"GDAL_HTTP_HEADERS": f"Authorization: Bearer {token}",
"GDAL_DISABLE_READDIR_ON_OPEN": "EMPTY_DIR",
}
with rio.Env(**gdal_env) as env:
with rio.open(url) as src:
print(src.meta)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment