[GRASS-dev] g.region -a results in a (slightly) different resolution

Dear devs,

As I understand, setting the a flag when defining a region should maintain the original resolution. So when setting different bounds based on a vector layer and with the a flag set, I would expect exactly the same resolution. Yet, the below output shows that this is not the case (even though differences are small). Am I misunderstanding something?

GRASS 7.3.svn (Latlon):~ > g.region -g

projection=3

zone=0

n=10

s=0

w=-80

e=-70

nsres=0.00025

ewres=0.00025

rows=40000

cols=40000

cells=1600000000

GRASS 7.3.svn (Latlon):~ > g.region -a vector=pastures

GRASS 7.3.svn (Latlon):~ > g.region -g

projection=3

zone=0

n=9.26125

s=9.1445

w=-79.85875

e=-79.6625

nsres=0.000250000000000003

ewres=0.00024999999999999

rows=467

cols=785

cells=366595

On Fri, Dec 23, 2016 at 3:54 PM, Paulo van Breugel
<p.vanbreugel@gmail.com> wrote:

Dear devs,

As I understand, setting the a flag when defining a region should maintain
the original resolution. So when setting different bounds based on a vector
layer and with the a flag set, I would expect exactly the same resolution.

... I think only, when you also use the res=xxx parameter.

https://grass.osgeo.org/grass72/manuals/g.region.html#notes
"With the -a flag all four boundaries are adjusted to be even
multiples of the resolution, aligning the region to the resolution
supplied by the user. The default is to align the region resolution to
match the region boundaries. "

Please try along with the res=value.

Markus

Strange, the behaviour I described only happens in one particular map set I was working in yesterday. I have tried out in different map sets now, and there it works as I expected, i.e., no need to supply the res=value argument. This is how I always assumed, and would hope, it to work. So depending on the intended behaviour, perhaps the note should be changed to:

ยทยทยท

On 23-12-16 16:00, Markus Neteler wrote:

On Fri, Dec 23, 2016 at 3:54 PM, Paulo van Breugel
[<p.vanbreugel@gmail.com>](mailto:p.vanbreugel@gmail.com) wrote:

Dear devs,

As I understand, setting the a flag when defining a region should maintain
the original resolution. So when setting different bounds based on a vector
layer and with the a flag set, I would expect exactly the same resolution.

... I think only, when you also use the res=xxx parameter.

[https://grass.osgeo.org/grass72/manuals/g.region.html#notes](https://grass.osgeo.org/grass72/manuals/g.region.html#notes)
"With the -a flag all four boundaries are adjusted to be even
multiples of the resolution, aligning the region to the resolution
supplied by the user. The default is to align the region resolution to
match the region boundaries. "

Please try along with the res=value.

Markus

# start region
> g.region -g
projection=99
zone=0
n=227830
s=220120
w=630970
e=638360
nsres=10
ewres=10
rows=771
cols=739
cells=569769

# setting region based on vector
> g.region save=test
> g.region vector=test
> g.region -g
projection=99
zone=0
n=226729.31747673
s=216615.56359876
w=630721.30299897
e=643766.80455016
nsres=10.00371303
ewres=9.99655291
rows=1011
cols=1305
cells=1319355

# resetting region, and then setting based on vector with a flag
> g.region region=test
> g.region -a vector=test
> g.region -g
projection=99
zone=0
n=226730
s=216610
w=630720
e=643770
nsres=10
ewres=10
rows=1012
cols=1305
cells=1320660

"By default the region resolution is aligned to match the region boundaries.
With the -a flag all four boundaries are adjusted to be even multiples of the
resolution, aligning the region to the resolution supplied by the user
(res=xxx), or, if not supplied, to the current resolution"

On Sat, Dec 24, 2016 at 10:40 AM, Paulo van Breugel
<p.vanbreugel@gmail.com> wrote:
...

So depending on
the intended behaviour, perhaps the note should be changed to:

"By default the region resolution is aligned to match the region boundaries.
With the -a flag all four boundaries are adjusted to be even multiples of
the
resolution, aligning the region to the resolution supplied by the user
(res=xxx), or, if not supplied, to the current resolution"

From this text change it is not obvious to me what to remove and what to keep.

Please send a diff, thanks.

Markus

On Wed, Dec 28, 2016 at 4:21 PM, Markus Neteler <neteler@osgeo.org> wrote:

On Sat, Dec 24, 2016 at 10:40 AM, Paulo van Breugel
<p.vanbreugel@gmail.com> wrote:
...
> So depending on
> the intended behaviour, perhaps the note should be changed to:
>
> "By default the region resolution is aligned to match the region
boundaries.
> With the -a flag all four boundaries are adjusted to be even multiples of
> the
> resolution, aligning the region to the resolution supplied by the user
> (res=xxx), or, if not supplied, to the current resolution"

From this text change it is not obvious to me what to remove and what to
keep.
Please send a diff, thanks.

Sorry for late response, was away. It seems the discussion on this topic is
ongoing, so let's see how that concludes

Markus