[GRASS5] G3D libraries notation

Glynn Clements glynn.clements at virgin.net
Wed Dec 4 12:57:33 EST 2002


Paul Kelly wrote:

> I don't know if the first element in GRASS raster row-column arrays is 0 or 1
> (in MATLAB it is 1; in C it is 0). If the first cell in the region is (row=0,
> column=0), then the corner of the region should be (x=-0.5, y=-0.5) or if the
> first cell is (row=1, column=1) then the corner of the region will be
> (x=0.5, y=0.5). Using this notation then the centre of each cell's "x-y"
> co-ordinates will be the same as the "row-column" co-ordinates for the cell.
> Having this offset of 0.5 in the "x-y" co-ordinates makes interpolation
> calculations etc. quite simple and intuitive.

I don't know about G3D, but for 2D GRASS rasters the index <0,0>
refers to the top-left (north-west) cell, while geographic coordinates
have north and east as the positive directions (i.e. the sense of the
geographic Y coordinate is opposite to that of cell rows).

The region corresponds to cell boundaries rather than centres, so:

1. ewres = (east-west)/cols, nsres = (north-south)/rows.

2. The top-left cell has index <0,0>, its top-left corner at
<west,north>, its bottom-right corner at <west+ewres,north-nsres> and
its centre at <west+ewres/2,north-nsres/2>.

3. The bottom-right cell has index <cols-1,rows-1>, its top-left
corner at <east-ewres,south+nsres>, its bottom-right corner at
<east,south> and its centre at <east-ewres/2,south+nsres/2>

4. An arbitrary cell with index <i,j> has its top-left corner at
<west+ewres*i,north-nsres*j>, its bottom-right corner at
<west+ewres*i+ewres,north-nsres*j-nsres> and its centre at
<west+ewres*i+ewres/2,north-nsres*j-nsres/2>

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-dev mailing list