[GRASS5] raster inaccuracy

glynn at gclements.plus.com glynn at gclements.plus.com
Wed Nov 10 09:49:24 EST 2004

Roger Miller wrote:

> I use Grass in part to support finite difference ground water models.  There
> is a substantial inaccuracy in Grass' raster representation that I've known of
> for some time.    The problem surfaced again recently, caused errors in my
> reported results and required me to repeat several hours of work at
> substantial costs.  I think this problem has been present from early betas of
> 5.0 through 5.3 (our current installation).
> The png file at
> http://members.spinn.net/~roger/mismatch.png
> illustrates the problem.  The image was produced by the Grass PNG driver.  It
> shows the top left corner of a model grid.  The lines are a vector map that
> outlines the individual model cells.  The colored blocks are a raster map
> developed from the vector map using v.to.rast.  The raster cells are not
> illustrated at the same locations as the cells of the vector map.
> The cells in this map are a mile across and the resolution of the region is
> set to one mile.  The actual size of the mismatch varies according to the
> location of the map origin, but even with the origin set exactly at the corner
> of the grid (where normally it is set) the raster cells do not correspond to
> the cells in the vector map.  The size of the mismatch is reduced by
> increasing the resolution of the region.  The difference is negligible if the
> row and column dimension of the region are reduced to a small fraction of the
> cell width - 1% worked well in this case, but such detailed resolutions are
> often not practical and shouldn't be necessary.
> The problem is not limited to the quality of the illustration.  My worst
> problem arose when the raster file was queried with d.what.rast.  The
> row-column location and category value produced by d.what.rast are the
> location and value of the raster cell as illustrated at a location, not the
> actual row-column location and category value at the location queried.
> I mapped a sites layer illustrating well locations over the raster map then
> queried the raster map to identify the row and column location for several
> wells.  I entered those wells into the ground water model based on the results
> of the query.  The wells were sometimes located in the correct model cell, but
> in other cases were assigned to one of the 8 surrounding model cells.
> I can only ask.  *Please* get this problem fixed.  Grass is a powerful tool,
> but this inaccuracy makes it very difficult for me to use Grass in my work.

First, I suspect that any discrepancy between vectors and rasters is
more likely to be in the vector code.

Also, bear in mind that GRASS' raster coordinate system is
"grid-registered" rather than "node-registered". E.g. the north-east
edge of the region is the location of the north-east corner of the
north-east cell, not of the centre of the north-east cell. If you are
given the region coordinates using a node-registered convention, you
have to expand the region by half a cell in each direction for use
with GRASS.

[BTW, GDAL has been known to get this wrong on occastion, i.e. failing
to add half a cell or adding it when it shouldn't; if you are
importing any data with GDAL, ensure that you have a recent version.]

For similar reasons, display modules which draw lines tend to be
problematic, as the display architecture uses integer coordinates, so
you can only place vertices on the corners of cells, not on their

In any case, in order to look into this any further, I would need
specific cases, i.e. a specific sequence of commands which can be
performed on data which I either have (e.g. spearfish, global) or can

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-dev mailing list