[GRASS-user] g.copy several map layers into one layer without overwriting .....

Glynn Clements glynn at gclements.plus.com
Wed Dec 5 08:54:09 PST 2012


Andranik Hayrapetyan wrote:

> I am trying to make a script which will split a raster map into chunks, do
> the calculation on every chunk separately ( in parallel way ), and gather
> together all the peaces.
> 
> So I am cutting the region into peaces, doing the calculation, restoring
> region to default region and finally get small peaces of raster map in it's
> default location and in default mapset.
> 
> Here is the problem of gathering the peaces together arises...
> 
> If I do it with r.patch, it is taking too long, and the whole meaning of
> parallelism is disappearing.
> 
> So I thought about g.copy .
> 
> Is there a way to copy all the peaces into one layer without overwriting
> the other peaces.

No.

> For example I have chunk_1 and chunk_2, which are the parts of one map.
>  How can I copy them into another map, so that they don't overwrite each
> other ?

For an uncompressed map, you can simply concatenate the cell/fcell
files (you still need to generate the metadata files, e.g. cellhd,
range, etc).

A compressed map starts with an array of row indices, and the rows
typically won't all have the same length (or necessarily be in order
and/or contiguous).

If you know that the individual maps are disjoint, it would be
possible to improve upon r.patch even while using the raster I/O API. 

In the case where the maps are disjoint vertical slices of the same
region, it would be possible to improve significantly upon the raster
I/O API by copying the compressed rows verbatim from the input
cell/fcell files to the output file. That would avoid decompression,
resampling and compression.

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


More information about the grass-user mailing list