Skip to content

Instantly share code, notes, and snippets.

@JesseCrocker
Created March 23, 2018 19:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Convert worldclim climate data to cloud optimized geotif

http://www.worldclim.org/current

wget http://biogeo.ucdavis.edu/data/climate/worldclim/1_4/grid/cur/tmin_30s_bil.zip
wget http://biogeo.ucdavis.edu/data/climate/worldclim/1_4/grid/cur/tmax_30s_bil.zip
wget http://biogeo.ucdavis.edu/data/climate/worldclim/1_4/grid/cur/tmean_30s_bil.zip
wget http://biogeo.ucdavis.edu/data/climate/worldclim/1_4/grid/cur/prec_30s_bil.zip

unzip tmin_30s_bil.zip
unzip tmax_30s_bil.zip
unzip tmean_30s_bil.zip
unzip prec_30s_bil.zip

mkdir tmp
mkdir clouded
for i in *.bil; do
    base=`basename $i .bil`
    gdalwarp -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=LZW -co ZLEVEL=9 -co TFW=NO $i tmp/$base.tif
    gdaladdo -r nearest tmp/$base.tif 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/$base.tif clouded/$base.tif
    rm tmp/$base.tif
done
rmdir tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment