[GRASS5] changing resolution - who decides
Glynn Clements
glynn.clements at virgin.net
Fri Apr 2 10:55:13 EST 2004
Andrea Antonello wrote:
> Who decides the values of the new resolutions, the number of cells to use and
> the values of the map to keep?
First, when you change the resolution, the new resolution will be
adjusted so that the number of rows and columns are both integers.
I.e. (north - south) will be an exact multiple of ns_res (or as close
as can be represented using floating point), and similarly for the
horizontal dimensions.
When you request a given cell, the coordinates of the cell's centre
are computed from the row/column indices and the current region's
boundaries and resolution:
northing = north - (row + 0.5) * ns_res
easting = west + (col + 0.5) * ew_res
The cell indices in the original map are then computed from the above
along with the boundaries and resolution of the original map:
row = round((north - northing) / ns_res)
col = round((easting - west ) / ew_res)
Note: the above is pseudo-code. The actual code used is in
src/libes/gis/window_map.c. The column->column mapping is cached in
the col_map field of each map's fileinfo structure, while the row->row
mapping is computed when the row is read.
Also, note that your first example is unstable. If you multiply the
resolution by an even number, the centre of each region cell will fall
on the boundary between cells in the original map, so even the tiniest
rounding error can affect which cell is actually chosen.
--
Glynn Clements <glynn.clements at virgin.net>
More information about the grass-dev
mailing list