[GRASS-user] how to g.region

Hamish hamish_nospam at yahoo.com
Wed Sep 12 22:35:28 EDT 2007


Raffaello Brondi wrote:
> i'm using GRASS 6.2 for developing a Web Processing Service.

Have you seen Jachym's PyWPS?
  http://pywps.wald.intevation.org

> One of the operations offered by the service takes two raster maps as 
> inputs.
> The raster map resulting from this operation would have different 
> spatial extents based on the input maps: the result would have the 
> extent equal to the extent of one of the two input maps, or equal to
> the union of the extents of the two input maps or equal to the
> intersection of the extents of the two raster maps.
> In order to develop the service i need to manage these four cases by 
> changing the GRASS region.
> Supposing that the input rasters are "raster1" and "raster2", the 
> possible configurations are:
> 
>    1. region = raster1 --> g.region rast=raster1
>    2. region = raster2 --> g.region rast=raster2
>    3. region = the union of raster1 and raster2 --> g.region 
> rast=raster1,raster2
>    4. region = the intersection of raster1 and raster2 --> ?
> 
> 
> As far as i see, using the g.region command, there is no way to specify 
> the last point except to manually set the nord,sud,ovest and east 
> values, but unfortunately i can not use this way.
> Is there any other command in GRASS that i can use instead of g.region 
> to set the current region as the intersection of two rasters?


This is not very efficient, and more like 'g.region zoom=', but you could
do:

g.region rast=map1,map2
r.mapcalc 'intersect= if(!isnull(map1) && !isnull(map2), 1, null())'
g.region zoom=intersect
g.remove intersect


But probably Wolf's method is what you want.


Hamish




More information about the grass-user mailing list