Skip to content

Instantly share code, notes, and snippets.

@grinsted
Created June 22, 2023 13:36
Show Gist options
  • Save grinsted/ec8338c3c3300dda779f6fd5c1b0c387 to your computer and use it in GitHub Desktop.
Save grinsted/ec8338c3c3300dda779f6fd5c1b0c387 to your computer and use it in GitHub Desktop.

Steps

  1. use earth engine to export a geotiff of the median modis in higher resolution than you need. https://code.earthengine.google.com/5ce94569601c58a14bcaf28c1852e006
  2. download them
  3. build a vrt file
gdalbuildvrt g.vrt greenland-modis-median-julyaugust-100m-*.tif
  1. convert it to a geotiff - e.g. lerc10
gdal_translate -of COG -co "COMPRESS=LERC_DEFLATE" -co "MAX_Z_ERROR=10" -a_nodata 0 -ot uint16 g.vrt -tr 250 250 -r lanczos greenland-modis-median-julyaugust-250m-lerc10.tif
  1. convert it to a jpeg compressed geotiff.
gdal_translate -of COG -co "COMPRESS=JPEG" -co "TILED=YES" -scale 0 10000 0 255 -a_nodata 0 -exponent .3 -ot byte -a_nodata 0 -tr 250 250 -r lanczos g.vrt greenland-modis-median-julyaugust-250m-jpeg.tif
  1. make a mask for the black pixels (this should probably be adjusted):
nearblack -setmask -nb 7 -near 20 greenland-modis-median-julyaugust-250m-jpeg.tif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment