[GRASS-dev] use of WIND_OVERRIDE in GRASS
Ivan Shmakov
ivan at theory.asu.ru
Mon Jan 7 04:27:01 EST 2008
>>>>> Glynn Clements <glynn at gclements.plus.com> writes:
>> exec `g.region rast="$RAST"`
> This is bogus on two counts. First, g.region doesn't output a shell
> command, so the use of exec and backticks makes no sense. Second,
> shell scripts shouldn't change the current region; they should create
> a temporary region with "g.region ... save=..." and use
> WIND_OVERRIDE.
Apparently, there're a couple of scripts to be fixed in GRASS
itself. An (untested) patch follows.
diff --git a/scripts/i.fusion.brovey/i.fusion.brovey b/scripts/i.fusion.brovey/i.fusion.brovey
index ce0be15..8cde5ea 100755
--- a/scripts/i.fusion.brovey/i.fusion.brovey
+++ b/scripts/i.fusion.brovey/i.fusion.brovey
@@ -118,8 +118,6 @@ export LC_NUMERIC
cleanup()
{
- #restore settings:
- g.region region=i.fusion.brovey.$TMP
g.remove region=i.fusion.brovey.$TMP > /dev/null
}
@@ -137,10 +135,12 @@ if [ $? -ne 0 ] ; then
exit 1
fi
-#save current settings:
+# clone current region
g.region save=i.fusion.brovey.$TMP > /dev/null
+WIND_OVERRIDE=i.fusion.brovey.$TMP
+export WIND_OVERRIDE
-g.message message="Temporarily setting raster resolution to PAN resolution: $PANRES"
+# set the resolution
g.region res=$PANRES -ap > /dev/null
g.message "Performing Brovey transformation..."
diff --git a/scripts/i.in.spotvgt/i.in.spotvgt b/scripts/i.in.spotvgt/i.in.spotvgt
index 826b307..25cbab1 100755
--- a/scripts/i.in.spotvgt/i.in.spotvgt
+++ b/scripts/i.in.spotvgt/i.in.spotvgt
@@ -200,8 +200,10 @@ g.message message="Imported SPOT VEGETATION NDVI map <$NAME>."
# Coefficient a = 0.004
# Coefficient b = -0.1
-#save region before zoom to SPOT image
-g.region save=spot_$PID 2>&1 >/dev/null
+# switch to a temporary region
+WIND_OVERRIDE=spot_$PID
+export WIND_OVERRIDE
+g.region -d 2>&1 >/dev/null
g.region rast=$NAME 2>&1 >/dev/null
g.message "Remapping digital numbers to NDVI..."
@@ -276,8 +278,7 @@ EOF
g.message message="Filtered SPOT VEGETATION NDVI map <${NAME}_filt>."
fi
-# restore user settings:
-g.region region=spot_$PID 2>&1 >/dev/null
+# remove the temporary region
g.remove region=spot_$PID 2>&1 >/dev/null
#### clean up the mess
More information about the grass-dev
mailing list