[GRASS-dev] Re: [gdal-dev] gdaldem hillshade directions / GRASS
r.shaded.relief
Even Rouault
even.rouault at mines-paris.org
Wed May 19 19:38:02 EDT 2010
Hamish,
I've taken some time to experiment a bit with GRASS and GRASS behaviour is
correct of course, so sorry for the noise.
I've finally identified why gdaldem (and initially Matt's hillshade utility)
got it wrong. GRASS r.mapcalc atan(x,y) function has its parameters reversed
in comparison to C atan2() used by GDAL : atan(x,y)=atan2(y,x)....
So the aspect computation was wrong which could also be seen as a wrong
interpretation of the azimuth parameter. But for the particular value of
az=315deg, the beauty of trigonometry makes it such that cos(az-pi/2-atan2
(y,x)) = cos(az-pi/2- atan2(x,y))...
Fixed as ticket http://trac.osgeo.org/gdal/ticket/3586
Best regards,
Even
Le Wednesday 19 May 2010 03:57:38 Hamish, vous avez écrit :
> Even wrote:
> > #correct azimuth to East (GRASS convention):
> > # this seems to be backwards, but in fact it works so
> > leave it.
> > az = float(azimuth) - 90
>
> I'm not into checking-in fudge factors which I don't understand,
> and I seem to recall that when I wrote that comment I did
> actually investigate the r.mapcalc algorithm and determine that
> it was "in fact" doing the right thing, or at least verified the
> output was correct.
>
> GRASS has, for decades, used the mathematical convention of
> theta measured CCW from the positive x-axis for measuring
> aspect, not the nautical convention of of degrees measured CW
> from north. Both ways are neither right nor wrong, it's just the
> convention used. (a reminder that grass's roots are in modeling
> and mathematical analysis, not cartography)
>
> The typical way to convert between the two conventions is:
> naut = 90 - theta
> theta = 90 - naut
>
>
> There is the possiblity that when gdal copied this code from
> GRASS they only got/rewrote half of it, or lost the matching
> color table, etc. ??
>
> If you like add it as a wish in the grass trac'er assigned to me,
> I could dig into it at some time in the future. sorry I don't
> have much time at all right now to look into itfurther. Only to
> say that I have looked into this in the past and signed off on
> it as ok back then (for use within GRASS, no idea about gdal's
> implimentation).
>
>
> hope that helps a little,
> Hamish
More information about the gdal-dev
mailing list