Opened 13 years ago

Closed 13 years ago

#1597 closed defect (fixed)

r.topidx ERROR current region resolution

Reported by: madi Owned by: grass-dev@…
Priority: normal Milestone: 6.5.0
Component: Raster Version: svn-develbranch6
Keywords: r.topidx Cc:
CPU: x86-64 Platform: Linux

Description

I get the following weird message: ERROR: Current region resolution [20.00x20.00] lower than input map resolution [20.00x20.00]

Attachments (1)

Screenshot.png (42.3 KB ) - added by madi 13 years ago.

Download all attachments as: .zip

Change History (14)

by madi, 13 years ago

Attachment: Screenshot.png added

comment:1 by neteler, 13 years ago

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.

comment:2 by hamish, 13 years ago

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

comment:3 by madi, 13 years ago

:~> 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

comment:4 by madi, 13 years ago

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

comment:5 by hamish, 13 years ago

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

comment:6 by hamish, 13 years ago

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

comment:7 by hamish, 13 years ago

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

Hamish

in reply to:  5 comment:8 by madi, 13 years ago

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

in reply to:  6 comment:9 by madi, 13 years ago

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

comment:10 by neteler, 13 years ago

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

comment:11 by hamish, 13 years ago

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

in reply to:  11 comment:12 by madi, 13 years ago

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

comment:13 by hamish, 13 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.