[GRASS-SVN] r34062 - grass/branches/develbranch_6/scripts/d.out.file

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Oct 29 09:40:09 EDT 2008


Author: hamish
Date: 2008-10-29 09:40:09 -0400 (Wed, 29 Oct 2008)
New Revision: 34062

Modified:
   grass/branches/develbranch_6/scripts/d.out.file/d.out.file
Log:
add flag to skip white margin crop. TODO: crop other formats

Modified: grass/branches/develbranch_6/scripts/d.out.file/d.out.file
===================================================================
--- grass/branches/develbranch_6/scripts/d.out.file/d.out.file	2008-10-29 13:39:12 UTC (rev 34061)
+++ grass/branches/develbranch_6/scripts/d.out.file/d.out.file	2008-10-29 13:40:09 UTC (rev 34062)
@@ -135,6 +135,11 @@
 #% description: Set paper orientation to landscape (for PostScript output)
 #% guisection: PostScript
 #%end
+#%flag
+#% key: m
+#% description: Do not crop away margins
+#% guisection: GeoTIFF
+#%end
 
 
 if  [ -z "$GISBASE" ] ; then
@@ -347,7 +352,8 @@
 d.mon start=$GRAPHICS_DRIVER --quiet
   # 'd.info -b' for white band removal
   BOX=`d.info -b | cut -f2 -d':'`
-  # use 'd.info -g' here for GeoTIFF bbox with no white band removal
+  # 'd.info -g' to get GeoTIFF bounds when keeping white margin bands
+  eval `d.info -g`
   eval "$dsave"
 d.mon stop=$GRAPHICS_DRIVER --quiet
 ################################
@@ -398,17 +404,24 @@
      ;;
    geotiff)
      g.message "Translating to GeoTIFF format" 
-     eval `g.region -g`
+     
+     if [ $GIS_FLAG_M -eq 0 ] ; then
+	# chop off out of region borders 
+	eval `g.region -g`
 
-     # chop off out of region borders 
-     BOX_L=`echo $BOX | cut -f1 -d' '`
-     BOX_R=`echo $BOX | cut -f2 -d' '`
-     BOX_T=`echo $BOX | cut -f3 -d' '`
-     BOX_B=`echo $BOX | cut -f4 -d' '`
-     BOX_WIDTH=`echo $BOX_R $BOX_L | awk '{print $1 - $2}'`
-     BOX_HEIGHT=`echo $BOX_B $BOX_T | awk '{print $1 - $2}'`
-     g.message "Image crop [$BOX_WIDTH x $BOX_HEIGHT]"
+	BOX_L=`echo $BOX | cut -f1 -d' '`
+	BOX_R=`echo $BOX | cut -f2 -d' '`
+	BOX_T=`echo $BOX | cut -f3 -d' '`
+	BOX_B=`echo $BOX | cut -f4 -d' '`
+	BOX_WIDTH=`echo $BOX_R $BOX_L | awk '{print $1 - $2}'`
+	BOX_HEIGHT=`echo $BOX_B $BOX_T | awk '{print $1 - $2}'`
 
+	CROP_PARAM="-srcwin $BOX_L $BOX_T $BOX_WIDTH $BOX_HEIGHT"
+	g.message "Image crop [$BOX_WIDTH x $BOX_HEIGHT]"
+     else
+	CROP_PARAM=""
+     fi
+
      PROJ_WKT="`g.proj -wf`"
      CO=""
      if [ -n "$GIS_OPT_CREATEOPT" ] ; then
@@ -426,8 +439,7 @@
      fi
      unset IFS
 
-     gdal_translate -of GTIFF -a_ullr $w $n $e $s -quiet \
-	-srcwin $BOX_L $BOX_T $BOX_WIDTH $BOX_HEIGHT \
+     gdal_translate -of GTIFF -a_ullr $w $n $e $s -quiet $CROP_PARAM \
 	-a_srs "$PROJ_WKT" $CO $MO "$output" "$outname"
      EXITCODE=$?
      ;;



More information about the grass-commit mailing list