Skip to content

Instantly share code, notes, and snippets.

Created October 22, 2014 04:39
What would you like to do?
echo "Enter bands in descending order, (ie 4 3 2)"
read B1 B2 B3
echo "Enter the resulting filename"
read outputname
#unzip all files in directory
for filename in *.tar
tar zxf $filename
#project each band epsg 3857, which is web mercator
for BAND in $B1 $B2 $B3; do
gdalwarp -t_srs EPSG:3857 *$BAND.TIF $BAND-projected.tif;
mkdir results$filename
for BAND in $B1 $B2 $B3; do
mv $BAND-projected.tif results$filename
cd results$filename
#combine the bands in one image
convert $B1-projected.tif $B2-projected.tif $B3-projected.tif -combine $filename.tif
#For most false colours this will get you half way to where you are going.
##Almost always needs to be adjusted.
convert -channel B -gamma 0.9 -channel G -gamma 1.0 -channel R -gamma 1.1 \
-channel RGB -sigmoidal-contrast 25x14% $filename.tif $filename-corrected.tif
#convert to 8 bit for tile mill rendering
convert -depth 8 $filename-corrected.tif $filename-corrected-8bit.tif
#create a geo reference file
listgeo -tfw $B3-projected.tif
#rename the file to match our created image
mv $B3-projected.tfw $filename-corrected-8bit.tfw
#srs, rename -a_srs EPSG:3857 $filename-corrected-8bit.tif
mv $filename-corrected-8bit.tif $outputname-projected.tif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment