[GRASSLIST:9362] Re: ArcInfo Grid vs r.in/out.gdal

Glynn Clements glynn at gclements.plus.com
Wed Dec 7 10:22:19 EST 2005


David Finlayson wrote:

> Maybe I misunderstood. I thought that you were referring to the
> coordinates of an arbitrary cell value (x, y), not the bounding box of
> the whole raster.
> 
> The only two raster registration systems that I have encountered are
> "raster" where the cell's value is located at the center of the cell,
> and "lattice" or "fishnet" where each corner of the cell has a value
> (really, the intersection of row and column lines).
> 
> In the former, there are row * col values.
> In the latter there are (rows + 1) * (cols +1) values.
> 
> You suggested that GRASS uses a variation on the "raster" format where
> instead of the cell center, the lower-left corner was the location of
> the value.

A cell's value is either a sample taken at the centre of the cell, or
the value for the cell as a whole, depending upon your perspective.
IOW, it's what you refer to as "raster" registration, and what GMT
refers to as "pixel" registration.

> This is a 1/2 X 1/2 cell shift in coordinates from what I expected.
> I've got a lot of code that is messed up if that is the case.

The bounds of a region (struct cell_hd) refer to the edges of the
region, i.e. the top-left corner of the top-left cell and the
bottom-left corner of the bottom-left cell.

Note that G_col_to_easting() and G_row_to_northing() take the col/row
as floating point values where (row,col) is the top-left corner,
(row+1,col+1) is the bottom-right corner, and (row+0.5,col+0.5) is the
centre. I.e. if you want the coordinates of the centre of the cell
with index (row,col), you would need to use:

	x = G_col_to_easting(col + 0.5, &wind);
	y = G_row_to_northing(row + 0.5, &wind);

where the top-left cell is (0,0) and the bottom-right cell is
(nrows-1,ncols-1).

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-user mailing list