How does GRASS do tiled processing?

5 messages Options
Embed this post
Permalink
Jonathan Greenberg

How does GRASS do tiled processing?

Reply Threaded More More options
Print post
Permalink
GRASSers:

    I was curious -- how is tiled processing realized in GRASS GIS?  Is
there a fixed input tile size (in MB of RAM or # of lines)?  Is there
some documentation buried on the GRASS site that describes the
algorithm?  I'm trying to replicate an efficient tiled approach in R --
I was basing it off the ENVI approach (precalculate the input data
memory footprint per line of data, read in as many lines as the memory
cap allows, process, write those lines, rinse, repeat), but I was
curious if GRASS had a different approach.

--j

--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Cell: 415-794-5043
AIM: jgrn307, MSN: [hidden email], Gchat: jgrn307

_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Milton Cezar Ribeiro

Re: How does GRASS do tiled processing?

Reply Threaded More More options
Print post
Permalink
Hi Jonathan,
 
When I need to do tiles processing of grass coupled R, I usually set a list of bounding boxes on R (a list of x1, x2, y1, y2), and then I put it on a for() looping. So, I set a new g.region using n= s= e= and w= parameters using system() function of R (you can do it of other ways). Just after the for() I reset g.region with -d.
 
*but* you need to be very careful with your processing, because some of the results will be influenced by the boundary of new sub-regions.
 
Good luck
 
milton
brazil=toronto

2009/7/8 Jonathan Greenberg <[hidden email]>
GRASSers:

  I was curious -- how is tiled processing realized in GRASS GIS?  Is there a fixed input tile size (in MB of RAM or # of lines)?  Is there some documentation buried on the GRASS site that describes the algorithm?  I'm trying to replicate an efficient tiled approach in R -- I was basing it off the ENVI approach (precalculate the input data memory footprint per line of data, read in as many lines as the memory cap allows, process, write those lines, rinse, repeat), but I was curious if GRASS had a different approach.

--j

--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Cell: 415-794-5043
AIM: jgrn307, MSN: [hidden email], Gchat: jgrn307
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user


_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Jonathan Greenberg

Re: How does GRASS do tiled processing?

Reply Threaded More More options
Print post
Permalink
Milton:

    Thanks, but I'm more curious in just the generic way GRASS does
tiled processing (say, in mapcalc).  I assume there is a low-level
processing layer GRASS uses (or no?).  I'm not doing a direct grass-to-R
link, I'm doing the processing completely within R with rgdal, but I'm
interested in various solutions to the tiled processing problem.

    That is a helpful suggestion, tho -- I used a similar approach when
I "forced" r.sun to do tiled processing with a massive lidar image I had
-- I ended up setting overlaps between each tile since its a spatial
problem.  For pure pixel analyses, of course, there's no need to worry
about boundaries...

--j

Milton Cezar Ribeiro wrote:

> Hi Jonathan,
>  
> When I need to do tiles processing of grass coupled R, I usually set a
> list of bounding boxes on R (a list of x1, x2, y1, y2), and then I put
> it on a for() looping. So, I set a new g.region using n= s= e= and w=
> parameters using system() function of R (you can do it of other ways).
> Just after the for() I reset g.region with -d.
>  
> *but* you need to be very careful with your processing, because some
> of the results will be influenced by the boundary of new sub-regions.
>  
> Good luck
>  
> milton
> brazil=toronto
>
> 2009/7/8 Jonathan Greenberg <[hidden email]
> <mailto:[hidden email]>>
>
>     GRASSers:
>
>       I was curious -- how is tiled processing realized in GRASS GIS?
>      Is there a fixed input tile size (in MB of RAM or # of lines)?
>      Is there some documentation buried on the GRASS site that
>     describes the algorithm?  I'm trying to replicate an efficient
>     tiled approach in R -- I was basing it off the ENVI approach
>     (precalculate the input data memory footprint per line of data,
>     read in as many lines as the memory cap allows, process, write
>     those lines, rinse, repeat), but I was curious if GRASS had a
>     different approach.
>
>     --j
>
>     --
>
>     Jonathan A. Greenberg, PhD
>     Postdoctoral Scholar
>     Center for Spatial Technologies and Remote Sensing (CSTARS)
>     University of California, Davis
>     One Shields Avenue
>     The Barn, Room 250N
>     Davis, CA 95616
>     Cell: 415-794-5043
>     AIM: jgrn307, MSN: [hidden email]
>     <mailto:[hidden email]>, Gchat: jgrn307
>     _______________________________________________
>     grass-user mailing list
>     [hidden email] <mailto:[hidden email]>
>     http://lists.osgeo.org/mailman/listinfo/grass-user
>
>

--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Cell: 415-794-5043
AIM: jgrn307, MSN: [hidden email], Gchat: jgrn307

_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
hamish-2

Re: How does GRASS do tiled processing?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Jonathan Greenberg

Jonathan wrote:

> > I was curious -- how is tiled processing realized in GRASS GIS?
> > Is there a fixed input tile size (in MB of RAM or # of lines)?
> > Is there some documentation buried on the GRASS site that
> > describes the algorithm?  I'm trying to replicate an efficient
> > tiled approach in R -- I was basing it off the ENVI approach
> > (precalculate the input data memory footprint per line of data,
> > read in as many lines as the memory cap allows, process, write
> > those lines, rinse, repeat), but I was curious if GRASS had a
> > different approach.
>
> [...] I'm more curious in just the
> generic way GRASS does tiled processing (say, in
> mapcalc).  I assume there is a low-level processing
> layer GRASS uses (or no?).  I'm not doing a direct
> grass-to-R link, I'm doing the processing completely within
> R with rgdal, but I'm interested in various solutions to the
> tiled processing problem.


most GRASS raster modules operate row by row. i.e. only one row of
map data is held in memory at a time. This goes a long way to explain
why it scales so well with minimal memory requirements.

This is mostly how r.mapcalc works, but due to its neighborhood operator
it may use the rows ahead & behind as well. (I'm not really sure) Also
note that r.mapcalc in GRASS 7 has experimental pthreads support multi-
threading on a multi-processor machine.

For modules which need to deal with all rows at once and hold all
those rows in memory, there is often a rows= option or memory= option
which lets you tell it how much of the map to store in memory at one
time, and then it does the job in a number of passes. e.g. v.to.rast,
r.in.xyz.

Other modules use a fixed amount of RAM. e.g. r.terraflow, r.watershed -m,
r.proj[.seg]. These will only use that much if actually needed, otherwise
they will use less. How that is done behind the scenes is module dependent.

e.g., some of them use the GRASS segment library to split the map up into
tiles during processing.  Actually, this is what 'r.watershed -m' is doing,
the max. memory option just tells it how big the segments can be. The
default r.watershed just tries to do everything in memory. r.los and
r.cost also use the segment library. It is considered to be slightly
inefficient.


may I inquire if you are more concerned with processing time (one tile per
processor on a multi-core) or memory use?  (sounds like memory use)

see raster/r.in.poly/raster.c in the source code for an example.


Hamish



     

_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Glynn Clements

Re: How does GRASS do tiled processing?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Jonathan Greenberg

Jonathan Greenberg wrote:

>     Thanks, but I'm more curious in just the generic way GRASS does
> tiled processing (say, in mapcalc).  I assume there is a low-level
> processing layer GRASS uses (or no?).

GRASS' primary raster processing model is row-by-row. Where possible,
the code reads a row, processes it, writes a row. If a neighbourhood
is required, the code typically maintains a scrolling window; it may
use the rowio library for this, or do it itself (r.mapcalc uses
rowio).

Modules which need uncorrelated access either read the entire map into
RAM, or use an uncompressed temporary file which may be a simple 2D
array or may be tiled. If it's tiled, the code may use the segment
library, or do it itself.

--
Glynn Clements <[hidden email]>
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user