[GRASSLIST:6069] Re: How deep is a region?
Hamish
hamish_nospam at yahoo.com
Wed Mar 9 01:37:14 EST 2005
> cellhd.depths should be inited to 1, Cho followed gis/adj_cellhd.c
> where
> cellhd->depths =
> (cellhd->top - cellhd->bottom + cellhd->tb_res/2.0) /
> cellhd->tb_res;
>
> I don't know why cellhd->tb_res/2.0, it is copy-paste of cols/rows.
Not fixed in CVS. [lib/gis/adj_cellhd.c]
AFAIU, "depths" is the z analogue of "cols" and "rows" in the region
settings; ie number of grid cells on the z-axis. For 2D rasters we are
always one cell thick so this is going to be 1 for the majority of maps.
So cellhd->depths needs to be an interger, as does cellhd->rows and
cellhd->cols.
but in the code:
cellhd->rows = (cellhd->north - cellhd->south + cellhd->ns_res/2.0) / cellhd->ns_res;
cellhd->cols = (cellhd->east - cellhd->west + cellhd->ew_res/2.0) / cellhd->ew_res;
.. it is leaving the cast to integer to the compiler. My C triva isn't
good enough to say for sure, but this is generally just an assumed
(int), right?
For clarity we should add cellhd->cols = (int) ((.. -+/2. ..)/ew_res);
if that is the intent? or should it be rounded instead of just stripping
digits to the right of the decimal point?
as for the /2.0 stuff, I don't know either. It has been like that for
rows & cols since the beginning of the CVS 5 years ago..
maybe Glynn [cc] understands.
Hamish
More information about the grass-user
mailing list