[GRASS-dev] [GRASS GIS] #1597: r.topidx ERROR current region resolution

#1597: r.topidx ERROR current region resolution
----------------------+-----------------------------------------------------
Reporter: madi | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Keywords: r.topidx | Platform: Linux
      Cpu: x86-64 |
----------------------+-----------------------------------------------------
I get the following weird message: ERROR: Current region resolution
[20.00x20.00] lower than input map resolution [20.00x20.00]

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

#1597: r.topidx ERROR current region resolution
----------------------+-----------------------------------------------------
Reporter: madi | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Keywords: r.topidx | Platform: Linux
      Cpu: x86-64 |
----------------------+-----------------------------------------------------

Comment(by neteler):

The code in question is in file_io.c:
{{{
     if (window.ew_res < inhead.ew_res || window.ns_res < inhead.ns_res)
         G_fatal_error(_("Current region resolution [%.2fx%.2f] lower than
input map resolution [%.2fx%.2f]! Needs to be at least identical or the
current region resolution lower than the input map resolution"),
                       window.ew_res, window.ns_res, inhead.ew_res,
                       inhead.ns_res);
}}}

I suspect that GRASS_EPSILON should be used here.

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

#1597: r.topidx ERROR current region resolution
----------------------+-----------------------------------------------------
Reporter: madi | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Keywords: r.topidx | Platform: Linux
      Cpu: x86-64 |
----------------------+-----------------------------------------------------

Comment(by hamish):

... or perhaps that 'g.region -a res=20' needs to be run in the mapset,
and the error message should use G_format_resolution() instead of %.2f
(which is unuseful for lat/lon)

what does "r.info -g input_map" and "g.region -p" say?

Hamish

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

#1597: r.topidx ERROR current region resolution
----------------------+-----------------------------------------------------
Reporter: madi | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Keywords: r.topidx | Platform: Linux
      Cpu: x86-64 |
----------------------+-----------------------------------------------------

Comment(by madi):

:~> r.info -g dem
north=4559778
south=4403628
east=669447
west=525987

:~ > g.region -p
projection: 1 (UTM)
zone: 33
datum: wgs84
ellipsoid: wgs84
north: 4559780
south: 4403620
west: 525980
east: 669460
nsres: 20
ewres: 20
rows: 7808
cols: 7174
cells: 56014592

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

#1597: r.topidx ERROR current region resolution
----------------------+-----------------------------------------------------
Reporter: madi | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Keywords: r.topidx | Platform: Linux
      Cpu: x86-64 |
----------------------+-----------------------------------------------------

Comment(by madi):

Running r.topidx after 'g.region -a res=20', I get the same error.

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

#1597: r.topidx ERROR current region resolution
----------------------+-----------------------------------------------------
Reporter: madi | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Keywords: r.topidx | Platform: Linux
      Cpu: x86-64 |
----------------------+-----------------------------------------------------

Comment(by hamish):

ok so the two grids don't match (your dem map is not on multiples of 20m,
its grid is offset), and it is being resampled. what does the full r.info
say? (everything between the Type of map: and Range of data: lines)

was it a self-made DEM or did you import it from some 3rd party source?
(ie can you remake it on a cleaner grid without loss?)

also try "g.region -p rast=dem" before r.topidx so that the region and the
map perfectly align the map's (offset) grid.

Hamish

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

#1597: r.topidx ERROR current region resolution
----------------------+-----------------------------------------------------
Reporter: madi | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Keywords: r.topidx | Platform: Linux
      Cpu: x86-64 |
----------------------+-----------------------------------------------------

Comment(by hamish):

> G_fatal_error(_("Current region resolution [%.2fx%.2f] lower than
> input map resolution [%.2fx%.2f]! Needs to be at least identical or
> the current region resolution lower than the input map resolution"),

shouldn't that read "Needs to be at least identical or the current region
resolution '''higher''' than ..." ?

Hamish

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

#1597: r.topidx ERROR current region resolution
----------------------+-----------------------------------------------------
Reporter: madi | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Keywords: r.topidx | Platform: Linux
      Cpu: x86-64 |
----------------------+-----------------------------------------------------

Comment(by hamish):

I've now updated the error message in all branches to be clearer and show
the region resolution at correct precision.

Hamish

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

#1597: r.topidx ERROR current region resolution
----------------------+-----------------------------------------------------
Reporter: madi | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Keywords: r.topidx | Platform: Linux
      Cpu: x86-64 |
----------------------+-----------------------------------------------------

Comment(by madi):

Replying to [comment:5 hamish]:
> ok so the two grids don't match (your dem map is not on multiples of
20m, its grid is offset), and it is being resampled. what does the full
r.info say? (everything between the Type of map: and Range of data: lines)
>
> was it a self-made DEM or did you import it from some 3rd party source?
(ie can you remake it on a cleaner grid without loss?)
>
> also try "g.region -p rast=dem" before r.topidx so that the region and
the map perfectly align the map's (offset) grid.
>
>
> Hamish

OK figured out:

g.region -p rast=dem
projection: 1 (UTM)
zone: 33
datum: wgs84
ellipsoid: wgs84
north: 4559778
south: 4403628
west: 525987
east: 669447
nsres: 20.0012809
ewres: 20
rows: 7807
cols: 7173
cells: 55999611

Now it works. Thanks.

madi

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

#1597: r.topidx ERROR current region resolution
----------------------+-----------------------------------------------------
Reporter: madi | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Keywords: r.topidx | Platform: Linux
      Cpu: x86-64 |
----------------------+-----------------------------------------------------

Comment(by madi):

Replying to [comment:6 hamish]:
> > G_fatal_error(_("Current region resolution [%.2fx%.2f] lower than
> > input map resolution [%.2fx%.2f]! Needs to be at least identical or
> > the current region resolution lower than the input map resolution"),
>
> shouldn't that read "Needs to be at least identical or the current
region resolution '''higher''' than ..." ?
>
>
> Hamish

Now it works, and current region (20) is '''lower''' than dem resolution
(20.0012809).

Thanks,
madi

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

#1597: r.topidx ERROR current region resolution
----------------------+-----------------------------------------------------
Reporter: madi | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Keywords: r.topidx | Platform: Linux
      Cpu: x86-64 |
----------------------+-----------------------------------------------------

Comment(by neteler):

Replying to [comment:8 madi]:
...
> g.region -p rast=dem
> projection: 1 (UTM)

...
> nsres: 20.0012809

Sidenote: This is a rather unfortunate resolution which indicates
a problem in the data preparation.

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

#1597: r.topidx ERROR current region resolution
----------------------+-----------------------------------------------------
Reporter: madi | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Keywords: r.topidx | Platform: Linux
      Cpu: x86-64 |
----------------------+-----------------------------------------------------

Comment(by hamish):

I think the old message could be confusing, the new one is

{{{
G_fatal_error(_("The current region resolution [%s x %s] is finer "
                  "than the input map's resolution [%s x %s]. "
                 "The current region resolution must be identical "
                 "to, or coarser than, the input map's resolution."),
}}}

with ew x ns resolution shown with G_format_resolution() instead of %.2f
which always rounds away the extra digits. Can you test and see if the new
version gives a more useful error when 'g.region res=20 -a' ?

thanks,
Hamish

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

#1597: r.topidx ERROR current region resolution
----------------------+-----------------------------------------------------
Reporter: madi | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Keywords: r.topidx | Platform: Linux
      Cpu: x86-64 |
----------------------+-----------------------------------------------------

Comment(by madi):

Replying to [comment:11 hamish]:
> I think the old message could be confusing, the new one is
>
> {{{
> G_fatal_error(_("The current region resolution [%s x %s] is finer "
> "than the input map's resolution [%s x %s]. "
> "The current region resolution must be identical "
> "to, or coarser than, the input map's resolution."),
> }}}
>
> with ew x ns resolution shown with G_format_resolution() instead of %.2f
which always rounds away the extra digits. Can you test and see if the new
version gives a more useful error when 'g.region res=20 -a' ?
>
>
> thanks,
> Hamish

ERROR: The current region resolution [20 x 20] is finer than the input
map's resolution [20 x 20.0012809]. The current region resolution must be
identical to, or coarser than, the input map's resolution.

This looks way better to me. Thanks a lot.
madi

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

#1597: r.topidx ERROR current region resolution
---------------------+------------------------------------------------------
  Reporter: madi | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 6.5.0
Component: Raster | Version: svn-develbranch6
Resolution: fixed | Keywords: r.topidx
  Platform: Linux | Cpu: x86-64
---------------------+------------------------------------------------------
Changes (by hamish):

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

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