Skip to content

Instantly share code, notes, and snippets.

@mikemahoney218
Created September 27, 2023 16:24
Show Gist options
  • Save mikemahoney218/d2e6760d4f05fe376900bf8c5fa6fc50 to your computer and use it in GitHub Desktop.
Save mikemahoney218/d2e6760d4f05fe376900bf8c5fa6fc50 to your computer and use it in GitHub Desktop.
# values specific to your stac source
# in this case, from
# https://planetarycomputer.microsoft.com/dataset/usgs-lcmap-conus-v13
COLLECTION="usgs-lcmap-conus-v13"
ASSET="lcpri"
# query parameters: bbox (wgs84) and datetime (utc)
# I grabbed these values from R
WGS84_BBOX="-79.762,40.496,-71.856,45.013"
DATETIME="2021-01-01/2021-12-31"
# output parameters
T_SRS="EPSG:5072"
# this is annoying: bbox representation in target srs
TE_XMIN=1324236
TE_YMIN=2150859
TE_XMAX=1991064
TE_YMAX=2658351
OUTPUT_FILE="lcpri_nys.tif"
# run the thing!
gdalwarp \
-t_srs $T_SRS -te $TE_XMIN $TE_YMIN $TE_XMAX $TE_YMAX \
"STACIT:\"https://planetarycomputer.microsoft.com/api/stac/v1/search?&collections=$COLLECTION&datetime=$DATETIME&bbox=$WGS84_BBOX\":asset=$ASSET" \
$OUTPUT_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment