Created
October 14, 2019 00:20
-
-
Save IReese/a935303ed619c54bde7488c6c65f9d40 to your computer and use it in GitHub Desktop.
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 | |
xmlfile=/gebco_template.xml | |
base_file=$1 | |
export_dir= | |
export_png= | |
export_xml= | |
file_name=$( basename $base_file | sed 's/.tif//' ) | |
echo $file_name | |
cat $xmlfile | sed -e "s/FILENAME/"${file_name}"/g" > $export_xml/${file_name}.xml | |
png_file=$export_png/${file_name}.png | |
echo $png_file | |
#png_file=$export_dir/${file_name}_NIWA_BLEND_forSENTINEL.png | |
nik2img.py $export_xml/${file_name}.xml $png_file --no-open -f PNG -d 9712 12840 | |
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" | |
} | |
ExtractedExtent=$(gdal_extent_gdalwarp_te "${base_file}") | |
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:3857 -a_ullr $flipextract $png_file $export_dir/${file_name}_fromPNG_to_tif.tif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment