Created
September 30, 2016 17:50
-
-
Save benelsen/e8f53ceccc7104a1634cc05ed3368169 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
#!/usr/bin/env zsh | |
tempfile=/tmp/${${2##*/}%.*}.temp.tiff | |
# pi=3.1415926536 | |
# h=35785831.00 # default | |
# h=35939462.66 | |
h=35862958.67 # <- correct | |
# r_a=35000.0 | |
# a=6378137.0 | |
# b=6356752.31414 | |
# width=4400.0 # 11000.0 | |
# height=width | |
# padding_x=26.0 #65.0 #20.0 | |
# padding_y=35.0 #87.0 #27.0 | |
def="+proj=geos +lon_0=140.7 +lat_0=0.0 +x_0=0.0 +y_0=0.0 +h=${h} +ellps=WGS84 +datum=WGS84 +units=m" | |
# phi1=1.419222962 # $(python -c "from math import acos; print acos( $a / ($a+$h) )" ) | |
# sinphi1=0.9885347335 # $(python -c "from math import sin; print sin( $phi1 )" ) | |
# phi2=1.419735066 # $(python -c "from math import acos; print acos( $b / ($a+$h) )" ) | |
# sinphi2=0.9886119283 # $(python -c "from math import sin; print sin( $phi2 )" ) | |
# echo "phi1: $((phi1 * 180.0 / pi))" | |
# echo "sinphi1: ${sinphi1}" | |
# echo "phi2: $((phi2 * 180.0 / pi))" | |
# echo "sinphi2: ${sinphi2}" | |
# psi1=0.1515733648 # $(( pi/2 - phi1 )) | |
# tanpsi1=0.1527449055 # $(python -c "from math import tan; print tan( $psi1 )" ) | |
# psi2=0.1510612608 # $(( pi/2 - phi2 )) | |
# tanpsi2=0.1522208946 # $(python -c "from math import tan; print tan( $psi2 )" ) | |
# echo "psi1: $((psi1 * 180.0 / pi))" | |
# echo "tanpsi1: ${tanpsi1}, $((1 - tanpsi1))" | |
# echo "psi2: $((psi2 * 180.0 / pi))" | |
# echo "tanpsi2: ${tanpsi2}, $((1 - tanpsi2))" | |
# r_x=1.0118181818 # $((1.0 + 2.0 * padding_x / width)) | |
# echo "r_x: ${r_x}" | |
# r_y=1.0159090909 # $((1.0 + 2.0 * padding_y / height)) | |
# echo "r_y: ${r_y}" | |
ulx=-5500111.4091 # $(( $(( -h * psi1 )) * ${r_x} )) | |
uly=5503691.3124 # $(( $(( +h * psi2 )) * ${r_y} )) | |
lrx=5500111.4091 # $(( $(( +h * psi1 )) * ${r_x} )) | |
lry=-5503691.3124 # $(( $(( -h * psi2 )) * ${r_y} )) | |
lon0=140.7 | |
lon1=56.94504951 # $((lon0 - 1.03 * phi1 * 180.0 / pi)) | |
lon2=224.45495049 # $((lon0 + 1.03 * phi1 * 180.0 / pi)) | |
lat0=0 | |
lat1=-83.785172129 # $((lat0 - 1.03 * phi2 * 180.0 / pi)) | |
lat2=83.785172129 # $((lat0 + 1.03 * phi2 * 180.0 / pi)) | |
gdal_translate -a_srs ${def} -a_ullr $ulx $uly $lrx $lry $1 $tempfile | |
gdalwarp -t_srs '+proj=latlong +ellps=WGS84 +datum=WGS84' -r cubic -overwrite -tr 0.04 0.04 -te $lon1 $lat1 $lon2 $lat2 -order 3 $tempfile $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment