[GRASS-dev] Re: [GRASS-user] r.what and d.what.rast

On Mon, 2 Oct 2006 18:13:16 +0200
Javier Álvarez Rodríguez wrote:

Hi all,
My problem is about I'm obtaining different results when using d.what.rast
and r.what.
Using interactively d.what.rast on a map named bas, I obtain these
results:

361421.875(E) 4540953.125(N)
bas in DATOS, quant (854)
bas in DATOS, actual (854.000000)

Then I write x and y coordinates in a file named pp3.txt

361421 4540953 (no matter real or integer coordinates)

and when using r.what
r.what bas@DATOS < pp3.txt
result is 860

I'm not sure of the cause, but in doing some tests of the same data
set, it would appear that r.what is probably reporting incorrectly.

I looked at the code briefly and can't see any obvious errors, but I'm
ccing the developers list to see if anyone has seen this bug before.

T
--
Trevor Wiens
twiens@interbaun.com

The significant problems that we face cannot be solved at the same
level of thinking we were at when we created them.
(Albert Einstein)

Trevor Wiens wrote:

Javier Álvarez Rodríguez wrote:

> Hi all,
> My problem is about I'm obtaining different results when using d.what.rast
> and r.what.
> Using interactively d.what.rast on a map named bas, I obtain these
> results:
>
> 361421.875(E) 4540953.125(N)
> bas in DATOS, quant (854)
> bas in DATOS, actual (854.000000)
>
> Then I write x and y coordinates in a file named pp3.txt
>
> 361421 4540953 (no matter real or integer coordinates)
>
> and when using r.what
> r.what bas@DATOS < pp3.txt
> result is 860

I'm not sure of the cause, but in doing some tests of the same data
set, it would appear that r.what is probably reporting incorrectly.

I looked at the code briefly and can't see any obvious errors, but I'm
ccing the developers list to see if anyone has seen this bug before.

The problem is with d.what.rast when zoomed out:

# spearfish dataset
G63> g.region elevation.10m
G63> d.rast elvation.10m

G63> d.what.rast

Buttons
Left: what's here
Right: quit

595509.1750503(E) 4920363.03822938(N)
elevation.10m in PERMANENT, quant (1432)
elevation.10m in PERMANENT, actual (1432.339600)

G63> r.what in=elevation.10m east_north=595509.1750503,4920363.03822938
595509.1750503|4920363.03822938||1432.65918

1432.339600 != 1432.65918

G63> r.stats -1gn elevation.10m | grep 1432.3396
595515 4920365 1432.3396

G63> r.stats -1gn elevation.10m | grep 1432.65918
595505 4920365 1432.65918

Indeed, reported x coordinate is off by one column.

G63> g.region n=4920450 s=n-100 e=595550 w=e-80
G63> d.redraw

G63> d.rast.num elevation.10m

G63> echo -e "width 2\nsymbol basic/circle 30 595509.1 4920363.0 yellow none" \
  | d.graph -m

G63> d.what.rast -c
595509.81707317(E) 4920363.23170732(N), 549(col) 763(row)
elevation.10m in PERMANENT, quant (1433)
elevation.10m in PERMANENT, actual (1432.659180)

595510.30487805(E) 4920363.23170732(N), 550(col) 763(row)
elevation.10m in PERMANENT, quant (1432)
elevation.10m in PERMANENT, actual (1432.339600)

So it works ok once zoomed in.

G63> r.what in=elevation.10m east_north=595509.81707317,4920364.20731707
595509.81707317|4920364.20731707||1432.65918

G63> r.what in=elevation.10m east_north=595510.06097561,4920364.08536585
595510.06097561|4920364.08536585||1432.3396

#zooming back out:
g.region rast=elevation.10m
d.redraw
echo -e "width 2\nsymbol basic/circle 5 595509.1 4920363.0 yellow none" \
  | d.graph -m
d.what.rast -c

595518.63321799(E) 4920366.76470588(N), 550(col) 763(row)
elevation.10m in PERMANENT, quant (1432)
elevation.10m in PERMANENT, actual (1432.462769)

G63> r.stats -1gn elevation.10m | grep 1432.462769
595515 4920375 1432.462769

now d.what.rast's y is off by one row ...

Hamish

ps - display/d.what.rast/what.c
  if (G_get_c_raster_row (fd[i], buf, row) < 0)

should that be G_get_raster_row(, type) ??