[GRASSLIST:4805] Re: accessing sparse cells...

Glynn Clements glynn at gclements.plus.com
Fri Nov 12 06:51:19 EST 2004


Massimiliano Cannata wrote:

> wich is the fastest approach to access in reading a writing sparse cells 
> of a raster map?
> 
> For every couple of  (row,col) not in sequential order do I have to read 
> the entire corrisponding row and then get the rigth col ?

Yes.

> Or maybe i 
> have to use an fseek to get the cell at the rigth position in the raster 
> file? Or is there a fastest way?

If the raster data is compressed (which is the default), you have to
at least decompress everything up to the cell you want.

If you need random access, either use the segment library, or write
your own equivalent, i.e. read in the entire map and write it to a
temporary file (or store it in memory) in a format which is more
appropriate for your access pattern.

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




More information about the grass-user mailing list