Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert NLCD to Cloud Optimized GeoTiff

NLCD data is published in 3x3 degree chunks, as tiff files inside a zip file. For processing this data it's far more convienent if the files are available directly as tiff files without having to unzip.

s3cmd get --skip-existing -r s3://prd-tnm/StagedProducts/NLCD/data/2011/landcover/3x3/
for i in *.zip; do unzip $i '*.tif'; done

mkdir tmp
mkdir clouded

for i in *.tif; do
gdalwarp -srcnodata 0 -dstnodata 0 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=LZW -co ZLEVEL=9 -co TFW=NO $i tmp/$i
gdaladdo -r nearest tmp/$i 2 4 8 16 32
gdal_translate -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=LZW -co ZLEVEL=9 -co TFW=NO -co COPY_SRC_OVERVIEWS=YES tmp/$i clouded/$i
rm tmp/$i
done

rmdir tmp

file sizes:

  • Original zip files: 3.7 gb
  • Unzipped tiff files: 20 gb
  • cloud optimized geotiffs: 2.3 gb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment