[GRASS-SVN] r30621 - grass/branches/releasebranch_6_3/scripts/i.in.spotvgt

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 18 11:54:11 EDT 2008


Author: neteler
Date: 2008-03-18 11:54:11 -0400 (Tue, 18 Mar 2008)
New Revision: 30621

Modified:
   grass/branches/releasebranch_6_3/scripts/i.in.spotvgt/description.html
   grass/branches/releasebranch_6_3/scripts/i.in.spotvgt/i.in.spotvgt
Log:
backported fixed from HEAD (trac #81)

Modified: grass/branches/releasebranch_6_3/scripts/i.in.spotvgt/description.html
===================================================================
--- grass/branches/releasebranch_6_3/scripts/i.in.spotvgt/description.html	2008-03-18 15:52:28 UTC (rev 30620)
+++ grass/branches/releasebranch_6_3/scripts/i.in.spotvgt/description.html	2008-03-18 15:54:11 UTC (rev 30621)
@@ -11,6 +11,9 @@
 
 <h2>NOTES</h2>
 
+The SPOT VGT files are delivered in HDF4 (Hierarchical Data Format Release 4)
+format. It is required to have the GDAL libraries installed with HDF4 support.
+
 <h3>Export of entire world SPOT VGT maps</h3>
 
 When working with SPOT VGT with entire world extent, it is recommended

Modified: grass/branches/releasebranch_6_3/scripts/i.in.spotvgt/i.in.spotvgt
===================================================================
--- grass/branches/releasebranch_6_3/scripts/i.in.spotvgt/i.in.spotvgt	2008-03-18 15:52:28 UTC (rev 30620)
+++ grass/branches/releasebranch_6_3/scripts/i.in.spotvgt/i.in.spotvgt	2008-03-18 15:54:11 UTC (rev 30621)
@@ -12,10 +12,14 @@
 #
 # COPYRIGHT:    (c) 2004,2007 GRASS Development Team
 #
+#               This program is free software under the GNU General Public
+#               License (>=v2). Read the file COPYING that comes with GRASS
+#               for details.
+#
 #############################################################################
 #
 # REQUIREMENTS:
-#      -  gdal: http://gdal.org
+#      -  gdal: http://www.gdal.org
 #
 # Notes:
 # * According to the faq (http://www.vgt.vito.be/faq/faq.html), SPOT vegetation 
@@ -124,11 +128,7 @@
  #echo $SOUTHCORNER
  #echo $RESOLUTION
 
- echo -n "<VRTDataset rasterXSize=" >> $1
- echo -n "\"$XSIZE\"" >> $1
- echo -n " rasterYSize=" >> $1
- echo "\"$YSIZE\">" >> $1
-
+ echo "<VRTDataset rasterXSize=\"$XSIZE\" rasterYSize=\"$YSIZE\">" >> "$1"
  echo " <SRS>GEOGCS[&quot;wgs84&quot;,DATUM[&quot;WGS_1984&quot;,SPHEROID[&quot;wgs84&quot;,6378137,298.257223563],TOWGS84[0.000,0.000,0.000]],PRIMEM[&quot;Greenwich&quot;,0],UNIT[&quot;degree&quot;,0.0174532925199433]]</SRS>" >> $1
  echo "   <GeoTransform>$WESTCORNER, $RESOLUTION, 0.0000000000000000e+00, $NORTHCORNER, 0.0000000000000e+00, -$RESOLUTION</GeoTransform>" >> $1
  echo "   <VRTRasterBand dataType=\"Byte\" band=\"1\">" >> $1
@@ -174,16 +174,16 @@
 
 ### create VRT header for NDVI
 
-PROJFILE=${SPOTDIR}/0001_LOG.TXT
-VRTFILE=$TMPFILE.vrt
+PROJFILE="${SPOTDIR}/0001_LOG.TXT"
+VRTFILE="$TMPFILE.vrt"
 
 # first process the NDVI:
-rm -f $VRTFILE
-create_VRT_file $VRTFILE $GIS_OPT_FILE
+rm -f "$VRTFILE"
+create_VRT_file "$VRTFILE" "$GIS_OPT_FILE"
 
 ## let's import the NDVI map...
 g.message "Importing SPOT VGT NDVI map..."
-r.in.gdal $VRTFILE output=$NAME
+r.in.gdal "$VRTFILE" output="$NAME"
 if [ $? -eq 1 ] ; then
    g.message -e "An error occurred. Stop."
    exit 1
@@ -200,17 +200,19 @@
 # Coefficient a = 0.004
 # Coefficient b = -0.1
 
-#save region before zoom to SPOT image
-g.region save=spot_$PID 2>&1 >/dev/null
-g.region rast=$NAME 2>&1 >/dev/null
+# switch to a temporary region
+WIND_OVERRIDE=spot_$PID
+export WIND_OVERRIDE
+g.region -d --quiet
+g.region rast="$NAME" --quiet
 
 g.message "Remapping digital numbers to NDVI..."
-r.mapcalc "${NAME}_$PID=0.004 * $NAME - 0.1"
-g.remove rast=$NAME 2>&1 >/dev/null
-g.rename rast=${NAME}_$PID,${NAME} >/dev/null
+r.mapcalc "${NAME}_$PID = 0.004 * $NAME - 0.1"
+g.remove rast="$NAME" --quiet
+g.rename rast="${NAME}_$PID","$NAME" --quiet
 
 #apply color table:
-r.colors ${NAME} color=ndvi 2>&1 >/dev/null
+r.colors "$NAME" color=ndvi --quiet
 
 ##########################
 # second, optionally process the SM quality map:
@@ -242,18 +244,18 @@
 
 if [ $GIS_FLAG_A -eq 1 ] ; then
   g.message "Importing SPOT VGT NDVI quality map..."
-  rm -f $VRTFILE
-  create_VRT_file $VRTFILE `echo ${GIS_OPT_FILE} | sed 's+NDV+SM+g'`
+  rm -f "$VRTFILE"
+  create_VRT_file "$VRTFILE" `echo ${GIS_OPT_FILE} | sed 's+NDV+SM+g'`
 
   ## let's import the SM quality map...
-  r.in.gdal $VRTFILE output=$NAME.sm
+  r.in.gdal "$VRTFILE" output="$NAME.sm"
   if [ $? -eq 1 ] ; then
      g.message -e "An error occurred. Stop."
      exit 1
   fi
 
 # some of the possible values:
-r.colors $NAME.sm col=rules << EOF
+r.colors "$NAME.sm" col=rules << EOF
 8 50 50 50
 11 70 70 70
 12 90 90 90
@@ -272,20 +274,19 @@
   g.message ""
   g.message message="Filtering NDVI map by Status Map quality layer..."
   r.mapcalc "${NAME}_filt=if($NAME.sm >= 248, $NAME, null() )"
-  r.colors ${NAME}_filt color=ndvi 2>&1 >/dev/null
+  r.colors "${NAME}_filt" color=ndvi --quiet
   g.message message="Filtered SPOT VEGETATION NDVI map <${NAME}_filt>."
 fi
 
-# restore user settings:
-g.region region=spot_$PID 2>&1 >/dev/null
-g.remove region=spot_$PID 2>&1 >/dev/null
+# remove the temporary region
+g.remove region="spot_$PID" --quiet
 
 #### clean up the mess
-rm -f $VRTFILE $TMPFILE
+rm -f "$VRTFILE" "$TMPFILE"
 
 #### end
 # write cmd history:
-r.support ${NAME} history="${CMDLINE}"
+r.support "$NAME" history="${CMDLINE}"
 
 g.message "Done."
 



More information about the grass-commit mailing list