[GRASS5] raster inaccuracy
glynn at gclements.plus.com
Thu Nov 11 13:15:28 EST 2004
Glynn Clements wrote:
> > I put together several examples that can be had from
> > http://members.spinn.net/~roger/example.tgz
> > The tar file produces a GRASS XY location named "example." The examples are
> > in the PERMANENT map set.
> > Here is the step-by-step procedure:
> > copy the tar file to our Grass data file hierarchy and unarchive the file
> > start Grass, using location "example" and mapset "PERMANENT"
> > "g.list vect" should list 6 vector files. Each file contains a simple grid
> > with square cells each 5280x5280.
> > Start with 2x2example. The procedure for all of the examples is identical.
> > "v.info 2x2example" to get the limits of the grid.
> > Use "g.region" to set the region to match the grid. In the case of 2x2example
> > the limits are n=10560 s=0 w=0 e=10560 nsres=5280 ewres=5280. In all examples
> > the resolution is 5280. The region so defined should have two rows and two
> > columns.
> > Ideally it seems like you should be able to set the region with "g.region
> > vect=2x2example." That may work, but in most examples it does not. If the
> > region is not set exactly to the dimensions of the grid then the next step
> > will produce unwanted results.
> > "v.to.rast i=2x2example o=2x2example"
> > "d.mon start=x0"
> > "d.rast -o 2x2example"
> > "d.vect 2x2example"
> > This should produce an accurate map, with the lines of the vector grid exactly
> > outlining the colored cells in the raster map.
> > "d.pan" and click on the image to recenter (e.g., click your pointer in the
> > center of the northwest cell). Repeat this step several times with different
> > center locations. With some centers the map is accurate. With other centers
> > the map is drawn with the raster file offset by half a cell width in both the
> > x and y directions. When there is an offset you can use d.where, d.what.rast
> > or d.what.vect to confirm that the vector map is correctly located (southwest
> > corner at x=0, y=0) and the raster map is offset.
> OK; I understand you now. At first glance, this appears to be a
> problem with the display library. I'll look into it, and get back to
I can see why this might be confusing; it had me confused for a while.
But this is the correct behaviour (from d.rast; d.pan is another
issue) It may not necessarily the behaviour which you want, but d.rast
is doing what it is supposed to.
The key point is that, in common with almost every other program which
operates upon rasters, d.rast isn't reading (or displaying) the
original raster, but the raster after it has been resampled according
to the current region settings.
If the current region has the same resolution as the raster, but isn't
aligned to the same grid, the result is that the raster which is
displayed on the monitor will be shifted by up to +/- half a cell.
This isn't an issue for vectors, as they aren't aligned to a grid.
If there's a flaw here, it's that d.pan appears to be aligning the
region to a half-cell grid. I have no idea why it does this, but it
probably shouldn't be performing any alignment. IOW, after panning,
the vector and the raster should be misaligned by an arbitrary amount
(in the range +/- half a cell), rather than by either half a cell or
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev