[GRASS5] Re: d.polar using d.graph

Markus Neteler neteler at itc.it
Thu Mar 16 17:12:14 EST 2006


Hamish,

On Fri, Mar 17, 2006 at 02:21:29AM +1300, Hamish wrote:
> Markus wrote:
> > The d.polar is waiting for a volunteer to change the xgraph
> > dependency to GRASS' d.graph. Maybe done in a few minutes for someone
> > who knows the syntax of d.graph input... The xgraph input
> > is just a title and coordinate pairs to draw the polar
> > diagram.
> 
> 
> well, here's a proof of concept; messy, but it does plot something--
> 
> `cat` and $FOO in d.graph's stdin is the required magic..
> 
> I've done it after-the-fact, but factoring x,y to 0-100% could be done 
> right in the "sin()*r, cos()*r" step to save time & space.

I wouldn't mind if someone improves the script.
 
> notes:
> my 1000x1000 aspect grid made 50mb temp files!
> 
> I got weird output when trying from r.slope.aspect (elev from 
> r.surf.contour). Spikes every 45degree. I thought I had my awk
> wrong.. [d.histogram of it attached]. Probably an artifact of blocky
> r.surf.contour output? That histogram is interesting.. smaller peaks
> 22.5deg out of phase with the 45deg spikes..? odd.

Check if you produced an integer DEM. If so, then it is no
surprise (see comments in r.slope.aspect manual).
 
> Is 0deg north-up or does it have to be rotated?  angle_n_up = 90-theta

0deg is East as common notion in GRASS (except for r.param.scale).
But north is up in the diagram (I think).

> The script could use lots of optimization.. move $2*$3/$4 stuff into one 
> coefficient before running awk, etc., e.g.
>   echo "\"All Data incl. NULL"           > ${TMP}_outercircle
>   RADIUS_COEFF=`echo "$TOTALNUMBER $TOTALVALIDNUMBER $MAXRADIUS" | \
>      awk '{printf "%.8f", $1/$2 * $3}'`
>   for i in `seq 0 360` ; do
>     echo "$i $RADIUS_COEFF" | awk ...

You are kindly invited to take a look.


> The following doesn't honour the undef= option, is it on purpose?
>  # unit vector on raw data converted to radians without no data:
>  cat ${TMP}_raw | grep -v '^*'| awk 'BEGIN {sum = 0.0}

No, fixed. 


> d.polar code follows (insert at end of script before cleanup)
> ---------------------

...

This looks promising. 
Maybe some power user picks it up and also adds the ring and
the directional indicator.

thanks for the proof of concept,

Markus




More information about the grass-dev mailing list