[STATSGRASS] rast.get and negative vectors

Roger Bivand Roger.Bivand at nhh.no
Sun Sep 26 09:39:53 EDT 2004


On 25 Sep 2004, Bob Cooper wrote:

> Hi,
> I am having a problem with rast.get and negative length vectors. First,
> I didn't know I had any (?). The only thing I can think of is I am
> working on data from the southern hemisphere where I have negative
> values for latitude. Below is a summary of gmeta() and of the output
> from my rast.get command.
> 
> summary(G)
> > Data from GRASS 5.0 LOCATION hectorsll with 87845 columns and 76288 rows;
> > Latitude-Longitude
> > The west-east range is: 172.5666, 173.3308,
> > and the south-north: -44.11695, -43.45325;
> > West-east cell sizes are 8.7e-06 units,
> > and south-north 8.7e-06 units.
> 

Well, a first guess would be that

> 87845*76288
[1] 6701519360

which would be too large anyway even on top-end 64-bit platforms (6.5G * 
bytes per cell). As of now in rastget.c, all of GR_ncols, GR_nrows, and 
ncells are declared as int, so cannot be larger than:

> .Machine$integer.max
[1] 2147483647

(on my 32-bit machine)

The problem will hit you when ncells is used to allocate memory, and where 
ncells has overflowed maximum integer. Since it seems unlikely that 
analysing multi-gigabyte rasters in R is sensible, changing the ints to 
longs is not a high priority, although compiled on a 64-bit machine, int 
may already allow higher values. Your cells seem to be 0.03 seconds 
square, about 1 meter? Do you need this level of resolution for your 
analysis, could you use g.region to choose a more manageable subset?

> 
> 
> > > topo <- rast.get(G, rlist="topo")
> > Error in rast.get(G, rlist = "topo") : negative length vectors are not allowed
> > >
> 
> Any hints would be greatly appreciated.
> 
> Bob Cooper
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no





More information about the grass-stats mailing list