[GRASS-SVN] r34043 - grass/branches/develbranch_6/scripts/d.out.file
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Oct 29 04:06:10 EDT 2008
Author: hamish
Date: 2008-10-29 04:06:10 -0400 (Wed, 29 Oct 2008)
New Revision: 34043
Modified:
grass/branches/develbranch_6/scripts/d.out.file/d.out.file
grass/branches/develbranch_6/scripts/d.out.file/description.html
Log:
* support GeoTIFF export
* less sleepy
* quieter gdal_translate
* fix gdal_translate option order
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 07:05:19 UTC (rev 34042)
+++ grass/branches/develbranch_6/scripts/d.out.file/d.out.file 2008-10-29 08:06:10 UTC (rev 34043)
@@ -29,7 +29,7 @@
#%option
#% key: format
#% type: string
-#% options: png,ppm,tif,jpg,bmp,ps,eps,svg,pdf
+#% options: png,ppm,tif,geotiff,jpg,bmp,ps,eps,svg,pdf
#% answer: png
#% description: Graphics file format
#% required : yes
@@ -100,6 +100,22 @@
#% guisection: PostScript
#% required : no
#% end
+#%option
+#% key: createopt
+#% type: string
+#% label: GeoTIFF creation option(s)
+#% description: In the form of "NAME=VALUE", separate multiple entries with a comma.
+#% guisection: GeoTIFF
+#% required : no
+#%end
+#%option
+#% key: metaopt
+#% type: string
+#% label: GeoTIFF metadata key(s) and value(s) to add
+#% description: In the form of "META-TAG=VALUE", separate multiple entries with a comma.
+#% guisection: GeoTIFF
+#% required : no
+#%end
#%flag
#% key: b
#% description: Set background color to black (white default)
@@ -217,7 +233,7 @@
png | ppm | ps | eps | svg | pdf)
output="${GIS_OPT_OUTPUT}.${GIS_OPT_FORMAT}"
;;
- tif | jpg)
+ tif | geotiff | jpg)
output="`g.tempfile pid=$$`.ppm"
;;
bmp)
@@ -229,8 +245,13 @@
;;
esac
-outname="${GIS_OPT_OUTPUT}.${GIS_OPT_FORMAT}"
+if [ "$GIS_OPT_FORMAT" = "geotiff" ] ; then
+ outname="${GIS_OPT_OUTPUT}.tif"
+else
+ outname="${GIS_OPT_OUTPUT}.${GIS_OPT_FORMAT}"
+fi
+
#is there a simpler way of testing for --overwrite?
if [ -e "$outname" ] ; then
if [ -z "$GRASS_OVERWRITE" ] || [ "$GRASS_OVERWRITE" -ne 1 ] ; then
@@ -337,10 +358,10 @@
g.message "Done."
exit
;;
- tif | jpg)
+ tif | geotiff | jpg)
# delay not needed if using GRASS_PNG_AUTO_WRITE ?
g.message "Waiting for file to write ..."
- sleep 5
+ sleep 2
;;
bmp)
if [ $GIS_FLAG_C -eq 1 ] ; then
@@ -349,7 +370,7 @@
else
# delay not needed if using GRASS_PNG_AUTO_WRITE ?
g.message "Waiting for file to write ..."
- sleep 5
+ sleep 2
fi
;;
esac
@@ -358,21 +379,47 @@
case "$GIS_OPT_FORMAT" in
tif)
g.message "Translating to TIFF format"
- gdal_translate "$output" "$outname" -of GTIFF
+ gdal_translate -of GTIFF -quiet "$output" "$outname"
EXITCODE=$?
;;
jpg)
g.message "Translating to JPEG format"
- gdal_translate "$output" "$outname" -of JPEG -co QUALITY="$GIS_OPT_QUALITY"
+ gdal_translate -of JPEG -co QUALITY="$GIS_OPT_QUALITY" \
+ -quiet "$output" "$outname"
EXITCODE=$?
;;
bmp)
g.message "Translating to BMP format"
- gdal_translate "$output" "$outname" -of BMP
+ gdal_translate -of BMP -quiet "$output" "$outname"
EXITCODE=$?
;;
+ geotiff)
+ g.message "Translating to GeoTIFF format"
+ eval `g.region -g`
+ PROJ_WKT="`g.proj -wf`"
+ CO=""
+ if [ -n "$GIS_OPT_CREATEOPT" ] ; then
+ IFS=,
+ for KEYVALUE in $GIS_OPT_CREATEOPT ; do
+ CO="$CO -co $KEYVALUE"
+ done
+ fi
+ MO=""
+ if [ -n "$GIS_OPT_METAOPT" ] ; then
+ IFS=,
+ for KEYVALUE in $GIS_OPT_METAOPT ; do
+ MO="$MO -mo $KEYVALUE"
+ done
+ fi
+ unset IFS
+
+ gdal_translate -of GTIFF -a_ullr $w $n $e $s -quiet \
+ -a_srs "$PROJ_WKT" $CO $MO "$output" "$outname"
+ EXITCODE=$?
+ ;;
esac
+
\rm "$output"
g.message "Done."
Modified: grass/branches/develbranch_6/scripts/d.out.file/description.html
===================================================================
--- grass/branches/develbranch_6/scripts/d.out.file/description.html 2008-10-29 07:05:19 UTC (rev 34042)
+++ grass/branches/develbranch_6/scripts/d.out.file/description.html 2008-10-29 08:06:10 UTC (rev 34043)
@@ -9,7 +9,7 @@
PNG and PPM formats are supported directly by the GRASS PNG driver and
PostScript output is supported directly by the GRASS PS driver.
<P>
-TIFF, JPEG, and BMP formats are supported by using <tt>gdal_translate</tt>
+TIFF, GeoTIFF, JPEG, and BMP formats are supported by using <tt>gdal_translate</tt>
on PPM format files produced by the GRASS PNG driver. Different levels of
compression/quality are supported for JPEG files.
<P>
@@ -23,7 +23,19 @@
Output from this module using the regular PostScript format may contain
subframes.
+<P>
+GeoTIFF export is provided as a convenience. For raster export
+it is generally preferable to use the <em>r.out.gdal</em> or
+<em>r.out.tiff</em> modules. The advantage of using <em>d.out.file</em>
+is that you can easily overlay multiple raster maps, vector maps,
+and decorations into the GeoTIFF at the expense of resolution and
+quality. If you wish to minimize the negative effects, use
+"<tt>g.region align=</tt>" or "<tt>g.region rast=</tt>", then
+"<tt>g.region -g</tt>" or "<tt>r.info -g</tt>" to discover the
+raster rows and columns of the map, and feed these numbers into
+<em>d.out.file</em>'s <b>size</b> parameter as columns,rows.
+
<H2>EXAMPLES</H2>
<h4>Speafish dataset</h4>
@@ -72,7 +84,11 @@
<A HREF="d.mon.html">d.mon</A>,
<A HREF="d.out.png.html">d.out.png</A>,
<A HREF="d.save.html">d.save</A>,
-<A HREF="ps.map.html">ps.map</A></EM><BR>
+<A HREF="g.region.html">g.region</A>,
+<A HREF="ps.map.html">ps.map</A>,
+<A HREF="r.out.gdal.html">r.out.gdal</A>,
+<A HREF="r.out.tiff.html">r.out.tiff</A>
+</EM><BR>
<A HREF="cairodriver.html">Cairo driver</A>,
<A HREF="pngdriver.html">PNG driver</A>,
<A HREF="psdriver.html">PostScript driver</A>,
More information about the grass-commit
mailing list