[GRASS-dev] r.distance problem: in our out?

Jachym Cepicky jachym.cepicky at centrum.cz
Tue Oct 10 09:33:56 EDT 2006


hallo,

On Wed, Oct 04, 2006 at 01:38:25PM +0200, Markus Neteler wrote:
> Hi,
> 
> for an application I have to calculate the distance between
> raster "objects". While this generally works, I have found
> that r.distance happily calculates the distance even if
> one object is within the other (say, raster pixel over
> raster polygon in second map). I would need an indication
> somehow that we are *in* (to ignore the distance in this
> case).

i did not found any G_is_null(raster_map_name,x,y) or similar function.
is there something like this?

thank you

jachym

one cell from mypixel is "surrounded" 
> 
> Spearfish example:
> 
> g.region -dp
> 
> # extract field #25:
> r.mapcalc "myarea=if(fields == 25, 1,null())"
> 
> # this archsite falls into field 25:
> v.extract archsites out=mypixel list=9
> v.to.rast mypixel out=mypixel use=val val=1
> r.distance mypixel,myarea 
> # -> reports two distant points
> 
> # zoom:
> g.region n=4926990 s=4925856 w=599850 e=601376 align=myarea
> d.mon x0
> d.rast myarea
> d.vect mypixel col=blue
> # visualize distance (d.graph give sometimes random output!):
> r.distance mypixel,myarea | awk -F: '{print "move",$4,$5,"\ndraw",$6,$7}' | d.graph -m
> 
> # generate points from distance for easier verification:
> r.distance mypixel,myarea | awk -F: '{print $4,"|",$5,"\n",$6,"|",$7}' | sed  's+ ++g' | v.in.ascii out=distance
> d.vect distance col=yellow
> 
> # cleanup:
> g.remove rast=myarea,mypixel
> g.remove vect=mypixel,distance
> 
> ###
> Problem: There is no indication that we are *within* the area. Maybe a flag is
> needed to optionally suppress the result in this case?
> Better ideas?
> 
> Second problem: The result seems to be underestimated by half a cell
> since not the cell edge is taken from the raster polygon boundary 
> but the cell center.
> 
> Appreciating help,
> Markus
> 
> _______________________________________________
> grass-dev mailing list
> grass-dev at grass.itc.it
> http://grass.itc.it/mailman/listinfo/grass-dev

-- 
Jachym Cepicky
e-mail: jachym.cepicky at centrum.cz
URL: http://les-ejk.cz
GPG: http://les-ejk.cz/gnupg_public_key/jachym_cepicky-gpg_public_key.asc
-----------------------------------------   
OFFICE:                                     
Department of Geoinformation Technologies 
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky at node.mendelu.cz
URL:    http://mapserver.mendelu.cz
Tel.:   +420 545 134 514
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20061010/addc0cd4/attachment.bin


More information about the grass-dev mailing list