Created
February 1, 2023 21:50
-
-
Save kapadia/8c25ff4f6659feda1105ae5e2e6dd7cc to your computer and use it in GitHub Desktop.
Interface with LP DAAC using Earthdata token
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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