Created
July 12, 2012 13:30
-
-
Save stoermerjp/3098104 to your computer and use it in GitHub Desktop.
DroneMapper.com: Basic Geo-referenced Mosaic Construction w/ GDAL (projection)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### | |
### JP Stoermer | |
### DroneMapper.com | |
### | |
### Clean up | |
rm -rf ./*._tif | |
rm -rf ./mosaic.tif | |
rm -rf ./mosaic.vrt | |
rm -rf ./mosaic.png | |
ARG1=$1 | |
WATERMARKS=$2 | |
### Rename JPGW if needed | |
for FILE in ./*.JPGw ; do NEWFILE=`echo $FILE | sed 's/.JPGw$/.jpgw/'` ; mv $FILE $NEWFILE ; done | |
### Find UTM Zone from JPGW | |
UTMZONE=`cat ./*.jpgw | grep UTM | awk -F" " {'print $4'} | head -1` | |
### Build GeoTIF | |
for FILE in ./*.JPG ; do NEWFILE=`echo $FILE | sed 's/.JPG$/._tif/'` ; /usr/bin/gdalwarp -t_srs "+proj=utm +zone=$UTMZONE +datum=WGS84" -wo "SKIP_NOSOURCE=yes" -r bilinear -dstnodata 255 $FILE $NEWFILE; done | |
### Build VRT | |
/usr/bin/gdalbuildvrt -resolution $ARG1 ./mosaic.vrt ./*._tif | |
### Build Final Mosaic | |
/usr/bin/gdalwarp -t_srs "+proj=utm +zone=$UTMZONE +datum=WGS84" -wo "SKIP_NOSOURCE=yet" -dstnodata 255 -r bilinear ./mosaic.vrt ./mosaic.tif | |
### Scale and Convert to PNG | |
convert ./mosaic.tif -transparent white -scale 5% ./mosaic.png | |
if [ $WATERMARKS == "watermarks" ] | |
then | |
composite -gravity center -dissolve 25 /www/html/files/dm_watermark_small.png ./mosaic.png ./mosaic.png | |
composite -dissolve 25 -tile /www/html/files/dm_watermark.png ./mosaic.tif ./mosaic.tif | |
fi | |
rm -rf ./*._tif | |
rm -rf ./mosaic.vrt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think "SKIP_NOSOURCE=yet" should be "SKIP_NOSOURCE=YES"