[GRASS-dev] [bug #4742] (grass) i.fusion.brovey,
i.in.spotvgt, v.rast.stats: don't use g.region
Michael Barton
michael.barton at asu.edu
Wed Jun 28 14:35:52 EDT 2006
Glynn's version was more compact, but I can answer your questions on my
version below.
Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University
phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton
> From: Hamish <hamish_nospam at yahoo.com>
> Date: Thu, 29 Jun 2006 02:45:13 +1200
> To: Michael Barton <michael.barton at asu.edu>
> Cc: <grass-dev at grass.itc.it>
> Subject: Re: [GRASS-dev] [bug #4742] (grass) i.fusion.brovey, i.in.spotvgt,
> v.rast.stats: don't use g.region
>
>> 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=)
Just being safe
>
>
>> 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)
>
Ah. This is where WIND_OVERRIDE (and GRASS_REGION) is useful. For all
functional purposes (display AND for any GIS operation like query or mapcalc
output) the region is reset to $input. BUT it is region.save that changes,
not WIND. Until WIND_OVERRIDE is reset, WIND just sets there and nothing
happens to it; region.save becomes the active WIND file for all activities.
>> do_stuff()
Same as above. All GIS functions behave as if region.save were WIND. WIND is
ignored.
>> unset WIND_OVERRIDE # unneeded if script exits, but good hygiene
Now WIND is NOT ignored; region.save is now treated like any normal saved
region file.
>> 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