[GRASS-dev] [bug #4469] (grass) g.region: nsres & ewres are rounded differently

Glynn Clements glynn at gclements.plus.com
Thu May 18 12:54:32 EDT 2006


Request Tracker wrote:

> this bug's URL: http://intevation.de/rt/webrt?serial_num=4469
> -------------------------------------------------------------------------
> 
> Subject: g.region: nsres & ewres are rounded differently
> 
> Platform: GNU/Linux/x86
> grass obtained from: CVS
> grass binary for platform: Compiled from Sources
> GRASS Version: 2006-05-18
> 
> Hi
> 
> nsres & ewres are rounded differently when setting res to something
> near the decimal places limit.
> 
> In [1] both nsres & ewres are rounded-down to 1.12345678 when
> requested res=1.123456784. That's OK.
> 
> But in [2], when requested one decimal point higher res=1.123456785,
> nsres is rounded-up to 1.12345679 while ewres is rounded-down to
> 1.12345678.
> 
> Moreover, next g.region run [3] with settings identical like in [2]
> results in ewres=nsres=1.12345678, and, naturaly, different region
> extent.
> 
> Is this all OK? I thought each single, identical g.region run should
> result in the exactly same region settings.

If you only specify the res= option, the new bounds will depend upon
the previous bounds.

Ultimately, a region is defined by its bounds and the number of rows
and columns. The resolution is derived from those values, and it may
not be possible to get exactly the value which you requested (as the
result of dividing a floating-point number by an integer may not be
exactly representable as a floating-point number).

The alternative (i.e. to define a region by one corner, the
resolution, and the number of rows and columns, with the other corner
being derived), would be signficantly more awkward to write code for.

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




More information about the grass-dev mailing list