[GRASS-dev] [bug #4742] (grass) i.fusion.brovey, i.in.spotvgt, v.rast.stats: don't use g.region

Hamish hamish_nospam at yahoo.com
Wed Jun 28 10:45:13 EDT 2006


> Actually, this is making it overly complicated. It should actually be
> as follows.
>
> g.region -u save=region.save # save a region but don't change WIND
> WIND_OVERRIDE=region.save
> export WIND_OVERRIDE # use region.save like WIND but don't change WIND
> g.region rast=$input
> do_stuff()
> unset WIND_OVERRIDE   # unneeded if script exits, but good hygiene
> g.remove region=region.save


I am not sure that the region code is 100% working as you expect......

step by step:

> g.region -u save=region.save # save a region but don't change WIND

it wouldn't change it anyway as no modifying parms were given? (like
rast=)


> WIND_OVERRIDE=region.save
> export WIND_OVERRIDE # use region.save like WIND but don't change WIND

ok

> g.region rast=$input

but now you have in fact changed the region [written to the WIND file]?
  (but the following modules are using WIND_OVERRIDE so you don't
notice)

> do_stuff()
> unset WIND_OVERRIDE   # unneeded if script exits, but good hygiene
> g.remove region=region.save


I'll work through a spearfish test as I don't have my head around this
fully:


G> g.region -d
G> g.region -p
projection: 1 (UTM)
zone:       13
datum:      nad27
ellipsoid:  clark66
north:      4928010
south:      4913700
west:       589980
east:       609000
nsres:      30
ewres:      30
rows:       477
cols:       634

G> g.region -u save=region.save
G> g.region -p
[same as above]

G> WIND_OVERRIDE=region.save
G> export WIND_OVERRIDE
G> g.region -p
[same as above]


G> g.region rast=elevation.10m
G> g.region -p
projection: 1 (UTM)
zone:       13
datum:      nad27
ellipsoid:  clark66
north:      4928000
south:      4914020
west:       590010
east:       609000
nsres:      10
ewres:      10
rows:       1398
cols:       1899

[changed!]

G> r.univar roads
 100%
total null and non-null cells: 2654802

[1398*1899 = 2654802 so region being used is elevation.10m not
region.save!]

G> unset WIND_OVERRIDE
G> g.remove region=region.save

#final:
G> g.region -p
projection: 1 (UTM)
zone:       13
datum:      nad27
ellipsoid:  clark66
north:      4928000
south:      4914020
west:       590010
east:       609000
nsres:      10
ewres:      10
rows:       1398
cols:       1899

[left in elevation.10m's region, not starting region!]




trying with Glynn's method:
> You don't need to touch the current region at all. Just:
>
>	g.region rast=$input save=region.tmp.$$
>	WIND_OVERRIDE=region.tmp.$$
>	export WIND_OVERRIDE
>	do_stuff()
>	g.remove region=region.tmp.$$


G> unset WIND_OVERRIDE
G> g.region -d
G> g.region -p
projection: 1 (UTM)
zone:       13
datum:      nad27
ellipsoid:  clark66
north:      4928010
south:      4913700
west:       589980
east:       609000
nsres:      30
ewres:      30
rows:       477
cols:       634


G> g.region rast=elevation.10m save=region.tmp.$$
G> g.region -p
projection: 1 (UTM)
zone:       13
datum:      nad27
ellipsoid:  clark66
north:      4928000
south:      4914020
west:       590010
east:       609000
nsres:      10
ewres:      10
rows:       1398
cols:       1899

[rrrrr. wrong. above needs "-u". let's try again, also with --o for
safety]

G> g.region -d
G> g.region -u rast=elevation.10m save=region.tmp.$$ --overwrite
G> g.region -p
..
nsres:      30
ewres:      30
..

[good; now region is still original but elevation.10m's region is saved]

G> WIND_OVERRIDE=region.tmp.$$
G> export WIND_OVERRIDE
G> g.region -p
..
nsres:      10
ewres:      10
rows:       1398
cols:       1899

[encouraging]

G> r.univar roads
 100%
total null and non-null cells: 2654802

[we are using 10m res region from region.tmp.$$]

G> cat $MAPSET/WIND | grep res | grep -v resol3
e-w resol:  30
n-s resol:  30
t-b resol:  1

[WIND is untouched, good]

G> unset WIND_OVERRIDE
G> g.remove region=region.tmp.$$

G> g.region -p
..
nsres:      30
ewres:      30
rows:       477
cols:       634

back where we started in default region.



perhaps this accounts for some occasional gis.m weirdness?


Hamish




More information about the grass-dev mailing list