Skip to content

Instantly share code, notes, and snippets.

@YKCzoli
Created October 22, 2014 04:39
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 YKCzoli/33e2bebe2d8793dc13a8 to your computer and use it in GitHub Desktop.
Save YKCzoli/33e2bebe2d8793dc13a8 to your computer and use it in GitHub Desktop.
L8FC.sh
#!/bin/bash
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
do
tar zxf $filename
done
filename=$B1$B2$B3
#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;
done
mkdir results$filename
for BAND in $B1 $B2 $B3; do
mv $BAND-projected.tif results$filename
done
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
gdal_edit.py -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