Created
October 8, 2019 21:04
-
-
Save IReese/5b06b79e9abda43739f60bbceb3e2ecf to your computer and use it in GitHub Desktop.
BASH for Creating Geotiff from Bathy PNG
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 | |
input_extent= | |
input_png= | |
output_loc= | |
function gdal_extent_gdalwarp_te() { | |
if [ -z "$1" ]; then | |
echo "Missing arguments. Syntax:" | |
echo " gdal_extent <input_raster>" | |
return | |
fi | |
EXTENT=$(gdalinfo "$1" |\ | |
grep "Lower Left\|Upper Right" |\ | |
sed "s/Lower Left //g;s/Upper Right //g;s/).*//g" |\ | |
#tr "\n" " " |\ | |
sed 's/ *$//g' |\ | |
tr -d "\n[(]'" |\ | |
sed 's/,/ /g') | |
echo -n "$EXTENT" | |
} | |
echo $input_png | |
file_name=$( basename $input_png | sed 's/.png//' ) | |
echo $file_name | |
ExtractedExtent=$(gdal_extent_gdalwarp_te "${input_extent}") | |
echo $ExtractedExtent | |
set -- $ExtractedExtent | |
flipextract=$( echo $1 $4 $3 $2 ) | |
#flipextract=$( echo $1 $2 $3 $4 ) | |
echo $flipextract | |
gdal_translate -of GTiff -a_srs epsg:3994 -a_ullr $flipextract $input_png $output_loc/$file_name.tif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment