Datasets:

Size:
n<1K
License:
io / preprocess.sh
ajstewart's picture
Upload 4 files
c9d9d26 verified
raw
history blame
1.64 kB
#!/usr/bin/env bash
set -euo pipefail
export GDAL_NUM_THREADS=ALL_CPUS
LANDSAT=(
LC09_L2SP_023032_20230620_20230622_02_T1_SR_B1.TIF
LC09_L2SP_023032_20230620_20230622_02_T1_SR_B2.TIF
LC09_L2SP_023032_20230620_20230622_02_T1_SR_B3.TIF
LC09_L2SP_023032_20230620_20230622_02_T1_SR_B4.TIF
LC09_L2SP_023032_20230620_20230622_02_T1_SR_B5.TIF
LC09_L2SP_023032_20230620_20230622_02_T1_SR_B6.TIF
LC09_L2SP_023032_20230620_20230622_02_T1_SR_B7.TIF
LC09_L2SP_023032_20230620_20230622_02_T1_SR_QA_AEROSOL.TIF
)
CDL=2023_30m_cdls.tif
SRS=EPSG:32616
# Raw (compress and clip)
rm -rf raw
mkdir raw raw/landsat raw/cdl
for FILE in ${LANDSAT[@]}
do
SRC=original/landsat/$FILE
DST=raw/landsat/$FILE
gdal_translate -co COMPRESS=LZW -co PREDICTOR=2 $SRC $DST
done
SRC=original/cdl/$CDL
DST=raw/cdl/$CDL
XMIN=229785
YMIN=4346385
XMAX=465315
YMAX=4585215
gdalwarp -te $XMIN $YMIN $XMAX $YMAX -te_srs $SRS -co COMPRESS=LZW -co PREDICTOR=2 $SRC $DST
# Preprocessed (CRS, RES, TAP, COG)
rm -rf preprocessed
mkdir preprocessed preprocessed/landsat preprocessed/cdl
RES=30
for FILE in ${LANDSAT[@]}
do
SRC=original/landsat/$FILE
DST=preprocessed/landsat/$FILE
gdalwarp -tr $RES $RES -tap -srcnodata 0 -dstnodata 0 -of COG -co COMPRESS=LZW -co PREDICTOR=2 $SRC $DST
done
XMIN=229800
YMIN=4346400
XMAX=465330
YMAX=4585230
SRC=original/cdl/$CDL
DST=preprocessed/cdl/$CDL
gdalwarp -t_srs $SRS -te $XMIN $YMIN $XMAX $YMAX -tr $RES $RES -tap -of COG -co COMPRESS=LZW -co PREDICTOR=2 $SRC $DST
# Tar
tar -czvf original.tar.gz original
tar -czvf raw.tar.gz raw
tar -czvf preprocessed.tar.gz preprocessed