[GRASS-user] g7 svn58117 r.random ERROR: There aren't [n] non-NULL cells in the current region

Hi all,

I’m having a small issue generating random points across a map with GRASS 7 svn rev. 58117. When running r.random I get the following error:

r.random land_cover_classification@PERMANENT vector_output=accuracy_assessment_random n=1000

Collecting Stats…
ERROR: There aren’t [1000] non-NULL cells in the current region
(Mon Oct 28 10:51:22 2013) Command finished (1 min 3 sec)

My region is:

g.region -p
projection: 99 (Lambert Conformal Conic)
zone: 0
datum: nad83
ellipsoid: grs80
north: 448953.41346712
south: 238997.2442541
west: 673974.37382019
east: 890151.92813758
nsres: 3.27959152
ewres: 3.27959152
rows: 64019
cols: 65916
cells: 4219876404

r.stats for the land cover map:

r.stats -c input=land_cover_classification@PERMANENT
1 89740438
2 767001523
3 824629190
4 76402738
5 331550200

  • 2130552315
    (Mon Oct 28 10:57:07 2013) Command finished (1 min 11 sec)

So, there are plenty of non-null cells in the region. Any input into what might be causing this error is much appreciated!

Thanks,
Eric

Some additional info: When I run r.random with the -i flag, I get the following results:

r.random -i input=land_cover_classification@PERMANENT n=1000 vector_output=accuraccy_assessment_random
Collecting Stats…
Raster: land_cover_classification@PERMANENT
Cover: (null)
Cell Count: -75090892
Null Cells: 2130552315

A negative cell count? hmmm…

···

On Mon, Oct 28, 2013 at 11:07 AM, Eric Goddard <egoddard1010@gmail.com> wrote:

Hi all,

I’m having a small issue generating random points across a map with GRASS 7 svn rev. 58117. When running r.random I get the following error:

r.random land_cover_classification@PERMANENT vector_output=accuracy_assessment_random n=1000

Collecting Stats…
ERROR: There aren’t [1000] non-NULL cells in the current region
(Mon Oct 28 10:51:22 2013) Command finished (1 min 3 sec)

My region is:

g.region -p
projection: 99 (Lambert Conformal Conic)
zone: 0
datum: nad83
ellipsoid: grs80
north: 448953.41346712
south: 238997.2442541
west: 673974.37382019
east: 890151.92813758
nsres: 3.27959152
ewres: 3.27959152
rows: 64019
cols: 65916
cells: 4219876404

r.stats for the land cover map:

r.stats -c input=land_cover_classification@PERMANENT
1 89740438
2 767001523
3 824629190
4 76402738
5 331550200

  • 2130552315
    (Mon Oct 28 10:57:07 2013) Command finished (1 min 11 sec)

So, there are plenty of non-null cells in the region. Any input into what might be causing this error is much appreciated!

Thanks,
Eric

Eric wrote:

rows: 64019
cols: 65916
cells: 4219876404

64019 * 65916 > signed 32bit integer so it overflows

is your system+grass 32 or 64 bit?

Cell Count: -75090892
Null Cells: 2130552315

A negative cell count? hmmm....

that may just be a cosmetic issue in the printf'ing of the variables.

the first thing I'd try is to go to line 124 in main.c and (1) remove
the two casts to (int), then (2) change the two %d to %ld.
(nCells and nNulls are defined as "long" in local_proto.h)

Hamish

Thanks, Hamish. My machine is 64 bit. Making those changes results in the same results posted above:

r.random -i --overwrite input=land_cover_classification@PERMANENT n=1000 vector_output=accuracy_assessment_random
Collecting Stats…
Raster: land_cover_classification@PERMANENT
Cover: (null)
Cell Count: -75090892
Null Cells: 2130552315

···

On Mon, Oct 28, 2013 at 2:01 PM, Hamish <hamish_b@yahoo.com> wrote:

Eric wrote:

rows: 64019
cols: 65916
cells: 4219876404

64019 * 65916 > signed 32bit integer so it overflows

is your system+grass 32 or 64 bit?

Cell Count: -75090892
Null Cells: 2130552315

A negative cell count? hmmm…

that may just be a cosmetic issue in the printf’ing of the variables.

the first thing I’d try is to go to line 124 in main.c and (1) remove
the two casts to (int), then (2) change the two %d to %ld.
(nCells and nNulls are defined as “long” in local_proto.h)

Hamish

Eric Goddard wrote:

Some additional info: When I run r.random with the -i flag, I get the
following results:
r.random -i input=land_cover_classification@PERMANENT n=1000
vector_output=accuraccy_assessment_random
Collecting Stats...
Raster: land_cover_classification@PERMANENT
Cover: (null)
Cell Count: -75090892
Null Cells: 2130552315

A negative cell count? hmmm....

Try r58118.

--
Glynn Clements <glynn@gclements.plus.com>

Thanks Glynn, it works now.

···

On Mon, Oct 28, 2013 at 8:34 PM, Glynn Clements <glynn@gclements.plus.com> wrote:

Eric Goddard wrote:

Some additional info: When I run r.random with the -i flag, I get the
following results:
r.random -i input=land_cover_classification@PERMANENT n=1000
vector_output=accuraccy_assessment_random
Collecting Stats…
Raster: land_cover_classification@PERMANENT
Cover: (null)
Cell Count: -75090892
Null Cells: 2130552315

A negative cell count? hmmm…

Try r58118.


Glynn Clements <glynn@gclements.plus.com>