[GRASS-dev] [GRASS GIS] #3509: g.region grow with negative number limited because of top and bottom

#3509: g.region grow with negative number limited because of top and bottom
-------------------------------------------------+-------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
     Type: defect | Status: new
Priority: minor | Milestone: 7.4.1
Component: Raster | Version: svn-trunk
Keywords: grow, shrink, g.region, expand | CPU: Unspecified
  computational region, extent, 3D |
Platform: Unspecified |
-------------------------------------------------+-------------------------
Here is what happens if you want to shrink region (grow < 0):

{{{
g.region -p raster=elevation
g.region -p grow=-1
# ERROR: Top must be larger than Bottom
g.region -p grow=2
g.region -p grow=-1
g.region -p grow=-1
g.region -p grow=-1
# ERROR: Top must be larger than Bottom
}}}

When you have small depth (1 by default) you can't do `grow=-1`.

''Please, add milestone 7.6.''

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3509&gt;
GRASS GIS <https://grass.osgeo.org>

#3509: g.region grow with negative number limited because of top and bottom
-------------------------+-------------------------------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: minor | Milestone: 7.6.0
Component: Raster | Version: svn-trunk
Resolution: | Keywords: grow, shrink, g.region, expand
       CPU: | computational region, extent, 3D
  Unspecified | Platform: Unspecified
-------------------------+-------------------------------------------------
Changes (by neteler):

* milestone: 7.4.1 => 7.6.0

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3509#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#3509: g.region grow with negative number limited because of top and bottom
-------------------------+-------------------------------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: minor | Milestone: 7.6.0
Component: Raster | Version: svn-trunk
Resolution: | Keywords: grow, shrink, g.region, expand
       CPU: | computational region, extent, 3D
  Unspecified | Platform: Unspecified
-------------------------+-------------------------------------------------
Changes (by lucadelu):

* Attachment "gregion.diff" added.

proposed patch

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3509&gt;
GRASS GIS <https://grass.osgeo.org>

#3509: g.region grow with negative number limited because of top and bottom
-------------------------+-------------------------------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: minor | Milestone: 7.6.0
Component: Raster | Version: svn-trunk
Resolution: | Keywords: grow, shrink, g.region, expand
       CPU: | computational region, extent, 3D
  Unspecified | Platform: Unspecified
-------------------------+-------------------------------------------------

Comment (by lucadelu):

I create this "workaround", I don't think a true fix could exist. It is
something like if a user decide to set the Top smaller then Bottom.

The same problem could append with extent

{{{
g.region -p raster=elevation
g.region nsres=13480 ewres=14980 rows=1 cols=1 -p
g.region -p grow=-1
ERROR: North must be larger than South
}}}

Should we also try to fix something like the error above? Or we should
just improve the output message?
I think this is not a bug but a user error or misunderstanding.

What do you think about the attached patch?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3509#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#3509: g.region grow with negative number limited because of top and bottom
-------------------------+-------------------------------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: minor | Milestone: 7.6.0
Component: Raster | Version: svn-trunk
Resolution: | Keywords: grow, shrink, g.region, expand
       CPU: | computational region, extent, 3D
  Unspecified | Platform: Unspecified
-------------------------+-------------------------------------------------

Comment (by wenzeslaus):

What about just ignoring the request for decrease when the minimal range
is reached? Not sure if that makes sense for X and Y, but it seems OK for
Z.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3509#comment:3&gt;
GRASS GIS <https://grass.osgeo.org>

#3509: g.region grow with negative number limited because of top and bottom
-------------------------+-------------------------------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: minor | Milestone: 7.6.0
Component: Raster | Version: svn-trunk
Resolution: | Keywords: grow, shrink, g.region, expand
       CPU: | computational region, extent, 3D
  Unspecified | Platform: Unspecified
-------------------------+-------------------------------------------------

Comment (by mmetz):

Replying to [comment:3 wenzeslaus]:
> What about just ignoring the request for decrease when the minimal range
is reached? Not sure if that makes sense for X and Y, but it seems OK for
Z.

+1

Introducing yet another flag is IMHO not a good idea, and it is against
the idea that the `grow` option should apply to all dimensions. I would
rather add a test for each dimension that the change results in a valid
region: top must be > bottom, east must be > west, north must be > south.
For latlon, north must be <= 90 degrees + 0.5 * ns_res, south must be >=
-90 degrees - 0.5 * ns_res. A warning could be printed if growing in a
specific dimension would result in an invalid region.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3509#comment:4&gt;
GRASS GIS <https://grass.osgeo.org>

#3509: g.region grow with negative number limited because of top and bottom
-------------------------+-------------------------------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: minor | Milestone: 7.6.0
Component: Raster | Version: svn-trunk
Resolution: fixed | Keywords: grow, shrink, g.region, expand
       CPU: | computational region, extent, 3D
  Unspecified | Platform: Unspecified
-------------------------+-------------------------------------------------
Changes (by mmetz):

* status: new => closed
* resolution: => fixed

Comment:

Fixed by lucadelu with r72397.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3509#comment:5&gt;
GRASS GIS <https://grass.osgeo.org>