Skip to content

Instantly share code, notes, and snippets.

@pnorman
Created January 5, 2014 06:10
Show Gist options
  • Save pnorman/8265005 to your computer and use it in GitHub Desktop.
Save pnorman/8265005 to your computer and use it in GitHub Desktop.
fun with landsat
gdal_translate -ot Byte -a_nodata 0 -scale 5655 15725 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene24}_B4.TIF" "${scene24}_B4_strech.tif" &
gdal_translate -ot Byte -a_nodata 0 -scale 5655 15725 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene25}_B4.TIF" "${scene25}_B4_strech.tif" &
gdal_translate -ot Byte -a_nodata 0 -scale 5655 15725 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene26}_B4.TIF" "${scene26}_B4_strech.tif" &
gdal_translate -ot Byte -a_nodata 0 -scale 6193 15287 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene24}_B3.TIF" "${scene24}_B3_strech.tif" &
gdal_translate -ot Byte -a_nodata 0 -scale 6193 15287 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene25}_B3.TIF" "${scene25}_B3_strech.tif" &
gdal_translate -ot Byte -a_nodata 0 -scale 6193 15287 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene26}_B3.TIF" "${scene26}_B3_strech.tif" &
gdal_translate -ot Byte -a_nodata 0 -scale 7105 15847 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene24}_B2.TIF" "${scene24}_B2_strech.tif" &
gdal_translate -ot Byte -a_nodata 0 -scale 7105 15847 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene25}_B2.TIF" "${scene25}_B2_strech.tif" &
gdal_translate -ot Byte -a_nodata 0 -scale 7105 15847 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene26}_B2.TIF" "${scene26}_B2_strech.tif" &
gdal_contrast_stretch -ndv 0 -outndv 0 -percentile-range 0.03 .99 ${scene24}_B8.TIF ${scene24}_B8_strech.tif & #pan
gdal_contrast_stretch -ndv 0 -outndv 0 -percentile-range 0.03 .99 ${scene25}_B8.TIF ${scene25}_B8_strech.tif & #pan
gdal_contrast_stretch -ndv 0 -outndv 0 -percentile-range 0.03 .99 ${scene26}_B8.TIF ${scene26}_B8_strech.tif & #pan
wait
gdal_landsat_pansharp -rgb ${scene24}_B4_strech.tif -rgb ${scene24}_B3_strech.tif -rgb ${scene24}_B2_strech.tif -pan ${scene24}_B8_strech.tif -ndv 0 -o ${scene24}_B432_pan.tif &
gdal_landsat_pansharp -rgb ${scene25}_B4_strech.tif -rgb ${scene25}_B3_strech.tif -rgb ${scene25}_B2_strech.tif -pan ${scene25}_B8_strech.tif -ndv 0 -o ${scene25}_B432_pan.tif &
gdal_landsat_pansharp -rgb ${scene26}_B4_strech.tif -rgb ${scene26}_B3_strech.tif -rgb ${scene26}_B2_strech.tif -pan ${scene26}_B8_strech.tif -ndv 0 -o ${scene26}_B432_pan.tif &
wait
gdalwarp --config GDAL_CACHEMAX 750 -co TILED=YES -wm 500 -srcnodata 0 -dstalpha ${scene24}_B432_pan.tif ${scene24}_B432_alpha.tif &
gdalwarp --config GDAL_CACHEMAX 750 -co TILED=YES -wm 500 -srcnodata 0 -dstalpha ${scene25}_B432_pan.tif ${scene25}_B432_alpha.tif &
gdalwarp --config GDAL_CACHEMAX 750 -co TILED=YES -wm 500 -srcnodata 0 -dstalpha ${scene26}_B432_pan.tif ${scene26}_B432_alpha.tif &
wait
GDAL_TIFF_INTERNAL_MASK=YES gdal_translate -mask 4 -b 1 -b 2 -b 3 \
-a_nodata none \
-co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=JPEG \
-co PHOTOMETRIC=YCBCR -co JPEG_QUALITY=97 -co INTERLEAVE=PIXEL \
${scene24}_B432_alpha.tif ${scene24}_B432.tif &
GDAL_TIFF_INTERNAL_MASK=YES gdal_translate -mask 4 -b 1 -b 2 -b 3 \
-a_nodata none \
-co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=JPEG \
-co PHOTOMETRIC=YCBCR -co JPEG_QUALITY=97 -co INTERLEAVE=PIXEL \
${scene25}_B432_alpha.tif ${scene25}_B432.tif &
GDAL_TIFF_INTERNAL_MASK=YES gdal_translate -mask 4 -b 1 -b 2 -b 3 \
-a_nodata none \
-co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=JPEG \
-co PHOTOMETRIC=YCBCR -co JPEG_QUALITY=97 -co INTERLEAVE=PIXEL \
${scene26}_B432_alpha.tif ${scene26}_B432.tif &
wait
gdaladdo -r gauss --config COMPRESS_OVERVIEW JPEG --config PHOTOMETRIC_OVERVIEW YCBCR --config INTERLEAVE_OVERVIEW PIXEL --config JPEG_QUALITY_OVERVIEW 97 --config TILED_OVERVIEW YES --config BLOCKXSIZE_OVERVIEW 512 --config BLOCKYSIZE_OVERVIEW 512 ${scene24}_B432.tif 2 4 8 16 32 64 128 256 &
gdaladdo -r gauss --config COMPRESS_OVERVIEW JPEG --config PHOTOMETRIC_OVERVIEW YCBCR --config INTERLEAVE_OVERVIEW PIXEL --config JPEG_QUALITY_OVERVIEW 97 --config TILED_OVERVIEW YES --config BLOCKXSIZE_OVERVIEW 512 --config BLOCKYSIZE_OVERVIEW 512 ${scene25}_B432.tif 2 4 8 16 32 64 128 256 &
gdaladdo -r gauss --config COMPRESS_OVERVIEW JPEG --config PHOTOMETRIC_OVERVIEW YCBCR --config INTERLEAVE_OVERVIEW PIXEL --config JPEG_QUALITY_OVERVIEW 97 --config TILED_OVERVIEW YES --config BLOCKXSIZE_OVERVIEW 512 --config BLOCKYSIZE_OVERVIEW 512 ${scene26}_B432.tif 2 4 8 16 32 64 128 256 &
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment