Skip to content

Instantly share code, notes, and snippets.

@oeon
Last active April 27, 2017 05:21
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save oeon/8007457 to your computer and use it in GitHub Desktop.
Save oeon/8007457 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

@ramotswa
Copy link

Hello,
I am trying to do exactly the same as you. My issue is that at the OTB stage I think something goes wrong. Although it processes it (I think), at the very end I get an error: "Inconsistency detected by ld.so: dl-close.c: 762: _dl_close: Assertion `map->l_init_called' failed!"
Do you get this? I read that this is merely a warning, and doesn't actually break anything but all my images after that stage are black with no data in them..
I am using landsat data just like yourself.. any tips would be greatly appreciated.
Thanks

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