Skip to content

Instantly share code, notes, and snippets.

@understar
Forked from oeon/landsat_notes.md
Created April 27, 2017 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save understar/603c47aff7578dcd86e1f47e5170dc13 to your computer and use it in GitHub Desktop.
Save understar/603c47aff7578dcd86e1f47e5170dc13 to your computer and use it in GitHub Desktop.
notes from processing Harmony Landsat post

##This workflow is only for the pansharpened images

####red-green-blue
gdalbuildvrt -separate -q -srcnodata "0 0 0" -vrtnodata "0 0 0" rgb.vrt LC80430352013339LGN00_B4.tif LC80430352013339LGN00_B3.tif LC80430352013339LGN00_B2.tif

####NIR, SWIR, and visible red
gdalbuildvrt -separate -q -srcnodata "0 0 0" -vrtnodata "0 0 0" false.vrt LC80430352013339LGN00_B5.tif LC80430352013339LGN00_B6.tif LC80430352013339LGN00_B4.tif

####color infrared
gdalbuildvrt -separate -q -srcnodata "0 0 0" -vrtnodata "0 0 0" cir.vrt LC80430352013339LGN00_B5.tif LC80430352013339LGN00_B3.tif LC80430352013339LGN00_B4.tif

####REMEMBER to edit .vrt to add <ColorInterp> tags

####orfeo time!
cd /Applications/QGIS.app/Contents/MacOS/bin/
./otbcli_BundleToPerfectSensor -ram 4096 -inp /Users/myuser/Desktop/LC80430352013339LGN00/LC80430352013339LGN00_B8.TIF -inxs /Users/myuser/Desktop/LC80430352013339LGN00/rgb.vrt -out /Users/myuser/Desktop/LC80430352013339LGN00/pansharp.tif uint16

./otbcli_BundleToPerfectSensor -ram 4096 -inp /Users/myuser/Desktop/LC80430352013339LGN00/LC80430352013339LGN00_B8.TIF -inxs /Users/myuser/Desktop/LC80430352013339LGN00/false.vrt -out /Users/myuser/Desktop/LC80430352013339LGN00/pansharp-false.tif uint16

./otbcli_BundleToPerfectSensor -ram 4096 -inp /Users/myuser/Desktop/LC80430352013339LGN00/LC80430352013339LGN00_B8.TIF -inxs /Users/myuser/Desktop/LC80430352013339LGN00/cir.vrt -out /Users/myuser/Desktop/LC80430352013339LGN00/pansharp-cir.tif uint16

####via @dwtkns https://github.com/dwtkns/gdal-cheat-sheet/blob/master/README.md#raster-operations
gdal_translate -ot Byte -scale 0 65535 0 255 -a_nodata "0 0 0" pansharp.tif pansharp-scaled.tif

gdal_translate -ot Byte -scale 0 65535 0 255 -a_nodata "0 0 0" pansharp-false.tif pansharp-false-scaled.tif

gdal_translate -ot Byte -scale 0 65535 0 255 -a_nodata "0 0 0" pansharp-cir.tif pansharp-cir-scaled.tif

####warp
gdalwarp -r cubic -wm 4096 -multi -srcnodata "0 0 0" -dstnodata "0 0 0" -dstalpha -wo OPTIMIZE_SIZE=TRUE -wo UNIFIED_SRC_NODATA=YES -t_srs EPSG:3857 -co TILED=YES -co COMPRESS=LZW -co tfw=yes pansharp-scaled.tif pansharp_3857.tif

gdalwarp -r cubic -wm 4096 -multi -srcnodata "0 0 0" -dstnodata "0 0 0" -dstalpha -wo OPTIMIZE_SIZE=TRUE -wo UNIFIED_SRC_NODATA=YES -t_srs EPSG:3857 -co TILED=YES -co COMPRESS=LZW -co tfw=yes pansharp-false-scaled.tif pansharp_false3857.tif

gdalwarp -r cubic -wm 4096 -multi -srcnodata "0 0 0" -dstnodata "0 0 0" -dstalpha -wo OPTIMIZE_SIZE=TRUE -wo UNIFIED_SRC_NODATA=YES -t_srs EPSG:3857 -co TILED=YES -co COMPRESS=LZW -co tfw=yes pansharp-cir-scaled.tif pansharp_cir3857.tif

####brighten
convert -sigmoidal-contrast 33x12% pansharp_3857.tif pansharp_3857-bright.tif

convert -sigmoidal-contrast 33x12% pansharp_false3857.tif pansharp_false3857-bright.tif

convert -sigmoidal-contrast 33x12% pansharp_cir3857.tif pansharp_cir3857-bright.tif

####give worldfile
cp pansharp_3857.tfw pansharp_3857-bright.tfw

cp pansharp_false3857.tfw pansharp_false3857-bright.tfw

cp pansharp_cir3857.tfw pansharp_cir3857-bright.tfw

####re-geo, rename
gdal_translate pansharp_3857-bright.tif harmony-rgb-pan.tif

gdal_translate pansharp_false3857-bright.tif harmony-false-pan.tif

gdal_translate pansharp_cir3857-bright.tif harmony-cir-pan.tif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment