#3509 closed defect (fixed)

g.region grow with negative number limited because of top and bottom

Reported by: wenzeslaus Owned by: grass-dev@…
Priority: minor Milestone: 7.6.0
Component: Raster Version: svn-trunk
Keywords: grow, shrink, g.region, expand computational region, extent, 3D Cc:
CPU: Unspecified Platform: Unspecified

Description

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.

Attachments (1)

gregion.diff (1.4 KB) - added by lucadelu 18 months ago.
proposed patch

Download all attachments as: .zip

Change History (6)

comment:1 Changed 18 months ago by neteler

Milestone: 7.4.17.6.0

Changed 18 months ago by lucadelu

Attachment: gregion.diff added

proposed patch

comment:2 Changed 18 months ago 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?

comment:3 Changed 18 months ago 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.

comment:4 in reply to:  3 Changed 18 months ago by mmetz

Replying to 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.

comment:5 Changed 12 months ago by mmetz

Resolution: fixed
Status: newclosed

Fixed by lucadelu with r72397.

Note: See TracTickets for help on using tickets.