Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save YKCzoli/e05ff3ea5b07952388b8 to your computer and use it in GitHub Desktop.
Mexico flood waters script
echo "Enter bands (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
for BAND in $B1 $B2 $B3; do
mv $BAND-projected.tif results
cd results
#combine the bands in one image
convert $B1-projected.tif $B2-projected.tif $B3-projected.tif -combine $filename.tif
#adjust the colors in two step process
convert -sigmoidal-contrast 50x15% $filename.tif $filename-adj.tif
convert -channel B -gamma 1.25 -channel G -gamma 1.25 \
-channel RGB -sigmoidal-contrast 25x25% $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