Skip to content

Instantly share code, notes, and snippets.

@hrwgc
Forked from springmeyer/orfeo-compile.sh
Last active December 11, 2015 21:49
Show Gist options
  • Save hrwgc/4665396 to your computer and use it in GitHub Desktop.
Save hrwgc/4665396 to your computer and use it in GitHub Desktop.

before

30 meter resolution EO1-ALI Satellite Image

After

10 meter resolution pansharpened EO1-ALI Satellite Image

brew install fltk
sudo pip install mercurial
hg clone http://hg.orfeo-toolbox.org/OTB
cd OTB
mkdir build
cmake \
-DBUILD_APPLICATIONS:BOOL=ON \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_C_FLAGS:STRING=-Wall -Wno-uninitialized -Wno-unused-variable -fPIC \
-DCMAKE_CXX_FLAGS:STRING= -Wall -Wno-deprecated -Wno-uninitialized -Wno-unused-variable -fPIC -Wno-gnu -Wno-overloaded-virtual \
../
#!/bin/bash
## test pansharpening script using EO1-ALI imagery obtained from USGS Earth Explorer.
## Bands 5, 4, 3 of E01-ALI represent R,G,B respectively, with 30m resolution.
## Band 1 is panchromatic, with 10m resolution.
gdalbuildvrt \
-separate \
-q \
-srcnodata "0 0 0"\
-vrtnodata "0 0 0"\
$DIR/rgb.vrt \
$DIR/*B05*.TIF $DIR/*B04*.TIF $DIR/*B03*.TIF && \
otbcli_BundleToPerfectSensor \
-ram 4096 \
-inp $DIR/*_B01_*.TIF \
-inxs $DIR/rgb.vrt \
-out $DIR/pan-${DIR}.tif uint16 && \
gdal_translate \
-ot Byte \
-scale 0 4000 0 255 \
-a_nodata "0 0 0" \
$DIR/pan-${DIR}.tif $DIR/pan-${DIR}-scaled.tif && \
gdalwarp \
-r lanczos \
-wm 4096 \
-multi \
-srcnodata "0 0 0" \
-dstnodata "0 0 0" \
-dstalpha \
-wo OPTIMIZE_SIZE=TRUE \
-wo UNIFIED_SRC_NODATA=YES \
-t_srs EPSG:3785 \
-co TILED=YES\
-co COMPRESS=LZW\
$DIR/pan-${DIR}-scaled.tif $DIR/pansharp_${DIR}_3785.tif &&\
gdaladdo \
-r cubic \
--config COMPRESS_OVERVIEW LZW \
$DIR/pansharp_${DIR}_3785.tif $ADDO && \
rm $DIR/pan-${DIR}.tif ${DIR}/pan-${DIR}-scaled.tif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment