[GRASS-user] could the region change between 2 commands in a single Bash script?

Glynn Clements glynn at gclements.plus.com
Thu Jun 1 12:31:07 EDT 2006


Maciek Sieczka wrote:

> I'm writing a Bash script that
> 
> 1. outputs the region settings into a temp file, to create a Grass
>    ASCII raster header (to be used in step 4)
> 
> 2. outputs 2 rasters to xyz ascii files
>    a. r.stats -1g raster1 > file1.xyz
>    b. r.stats -1g raster2 > file2.xyz
> 
> 3. processes them, converts the resust into a single Grass ASCII raster
> 
> 4. imports it with r.in.ascii (header created based on region settings
>    obtained in step 1)
> 
> 2a and 2b might take some time.
> 
> The question: if I run my script in background, and then I change the
> region before eg. step 2a completes, is there any danger that 2b will
> be run in a different region?

Yes.

However, you can force the use of a different region by setting either
of the environment variables WIND_OVERRIDE or GRASS_REGION.

WIND_OVERRIDE should be the name of a saved region (created with e.g. 
"g.region save=..."), while GRASS region should be a complete region
definition in the same format as a region file except that newlines
are replaced with semicolons.

E.g.

	region=myscript.$$
	g.region save=$region
	export WIND_OVERRIDE=$region

	...

	g.remove region=$region

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




More information about the grass-user mailing list