[GRASS-dev] [bug #5043] (grass) r.out.gdal does not export "g.region -p"

this bug's URL: http://intevation.de/rt/webrt?serial_num=5043
-------------------------------------------------------------------------

Subject: r.out.gdal does not export "g.region -p"

Platform: GNU/Linux/x86
grass obtained from: Other (CDROM etc)
grass binary for platform: Downloaded precompiled Binaries
GRASS Version: GRASS 6.0.2 (2006)

r.out.gdal does export the region as defined in "g.region -p", but the full input raster file. (my gdalwarp is also a standard debian binary, GDAL 1.3.1.0, released 2005/10/04.)
on the spearfish60 data set I get the following:

GRASS 6.0.2 (spearfish60):

# exemplary data
d.rast elevation.dem
# set to arbitrary region
g.region n=4926900 s=4923600 e=604800 w=601200
d.redraw

# export to tiff
r.out.tiff input=elevation.dem output=tmp1

# the resulting "tmp1.tif" is equal to
g.region n=4926900 s=4923600 e=604800 w=601200
d.redraw
# -> as expected

# export to gtiff
r.out.gdal input=elevation.dem output=tmp2.tif type=UInt16

# the resulting "tmp2.tif" is equal to the full raster file:
g.region county
d.redraw

-------------------------------------------- Managed by Request Tracker

On Thu, Aug 24, 2006 at 02:11:12PM +0200, Request Tracker wrote:

this bug's URL: http://intevation.de/rt/webrt?serial_num=5043
-------------------------------------------------------------------------

Subject: r.out.gdal does not export "g.region -p"

Platform: GNU/Linux/x86
grass obtained from: Other (CDROM etc)
grass binary for platform: Downloaded precompiled Binaries
GRASS Version: GRASS 6.0.2 (2006)

r.out.gdal does export the region as defined in "g.region -p", but the full input raster file.

I just found that it is pretty easy to support at least
the current region extent:

diff -u -r1.24 r.out.gdal
--- r.out.gdal 19 Aug 2006 12:52:24 -0000 1.24
+++ r.out.gdal 24 Aug 2006 12:54:58 -0000
@@ -129,9 +129,11 @@
   unset METAKEY
fi

+eval `g.region -g`
+
#do it
CELLHD=`echo $file | sed 's+/cell/+/cellhd/+g'`
echo "Writing format: $FORMAT"
echo "Writing type: $TYPE"
-gdal_translate -of $FORMAT -ot $TYPE $CREATEKEY $METAKEY $CELLHD $OUTPUT
+gdal_translate -of $FORMAT -ot $TYPE $CREATEKEY $METAKEY -projwin $w $n $e $s $CELLHD $OUTPUT

For current resolution support, I have no idea.

Opinions about above change?

Markus

Markus Neteler napisa?(a):

On Thu, Aug 24, 2006 at 02:11:12PM +0200, Request Tracker wrote:

this bug's URL: http://intevation.de/rt/webrt?serial_num=5043
-------------------------------------------------------------------------

Subject: r.out.gdal does not export "g.region -p"

Platform: GNU/Linux/x86
grass obtained from: Other (CDROM etc)
grass binary for platform: Downloaded precompiled Binaries
GRASS Version: GRASS 6.0.2 (2006)

r.out.gdal does export the region as defined in "g.region -p", but the full input raster file.

I just found that it is pretty easy to support at least
the current region extent:

diff -u -r1.24 r.out.gdal
--- r.out.gdal 19 Aug 2006 12:52:24 -0000 1.24
+++ r.out.gdal 24 Aug 2006 12:54:58 -0000
@@ -129,9 +129,11 @@
   unset METAKEY
fi

+eval `g.region -g`
+
#do it
CELLHD=`echo $file | sed 's+/cell/+/cellhd/+g'`
echo "Writing format: $FORMAT"
echo "Writing type: $TYPE"
-gdal_translate -of $FORMAT -ot $TYPE $CREATEKEY $METAKEY $CELLHD $OUTPUT
+gdal_translate -of $FORMAT -ot $TYPE $CREATEKEY $METAKEY -projwin $w $n $e $s $CELLHD $OUTPUT

For current resolution support, I have no idea.

Opinions about above change?

I personally like the way r.out.gdal behaves now, as usually I need to
export full rasters I create, not a parts of them. Present r.out.gdal
bahaviour saves me fiddling with g.region prior to export. The
trim-to-current-region behavior would be nice as an option though (no
need for intermediate r.mapcalc then). My 0,01 PLN.

As to resolution, maybe this would work:

gdalwarp -of $FORMAT -ot $TYPE $CREATEKEY -te $w $n $e $s -tr $ewres
$nsres $CELLHD $OUTPUT

I don't know how to substitute gdal_translate's -mo in gdalwarp. -wo?

Maciek

P.S.
If the gdalwarp approach would be OK, this report would become a
duplicate of wish http://intevation.de/rt/webrt?serial_num=3271.

I knew there was another reason I preferred r.out.tiff (besides easier to remember options). r.out.tiff uses the region settings.

On Aug 24, 2006, at 9:17 AM, Maciej Sieczka wrote:

Markus Neteler napisa?(a):

On Thu, Aug 24, 2006 at 02:11:12PM +0200, Request Tracker wrote:

this bug's URL: http://intevation.de/rt/webrt?serial_num=5043
-------------------------------------------------------------------------

Subject: r.out.gdal does not export "g.region -p"

Platform: GNU/Linux/x86
grass obtained from: Other (CDROM etc)
grass binary for platform: Downloaded precompiled Binaries
GRASS Version: GRASS 6.0.2 (2006)

r.out.gdal does export the region as defined in "g.region -p", but the full input raster file.

I just found that it is pretty easy to support at least
the current region extent:

diff -u -r1.24 r.out.gdal
--- r.out.gdal 19 Aug 2006 12:52:24 -0000 1.24
+++ r.out.gdal 24 Aug 2006 12:54:58 -0000
@@ -129,9 +129,11 @@
   unset METAKEY
fi

+eval `g.region -g`
+
#do it
CELLHD=`echo $file | sed 's+/cell/+/cellhd/+g'`
echo "Writing format: $FORMAT"
echo "Writing type: $TYPE"
-gdal_translate -of $FORMAT -ot $TYPE $CREATEKEY $METAKEY $CELLHD $OUTPUT
+gdal_translate -of $FORMAT -ot $TYPE $CREATEKEY $METAKEY -projwin $w $n $e $s $CELLHD $OUTPUT

For current resolution support, I have no idea.

Opinions about above change?

I personally like the way r.out.gdal behaves now, as usually I need to
export full rasters I create, not a parts of them. Present r.out.gdal
bahaviour saves me fiddling with g.region prior to export. The
trim-to-current-region behavior would be nice as an option though (no
need for intermediate r.mapcalc then). My 0,01 PLN.

As to resolution, maybe this would work:

gdalwarp -of $FORMAT -ot $TYPE $CREATEKEY -te $w $n $e $s -tr $ewres
$nsres $CELLHD $OUTPUT

I don't know how to substitute gdal_translate's -mo in gdalwarp. -wo?

Maciek

P.S.
If the gdalwarp approach would be OK, this report would become a
duplicate of wish http://intevation.de/rt/webrt?serial_num=3271.

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

-----
William Kyngesburye <kyngchaos@kyngchaos.com>
http://www.kyngchaos.com/

"This is a question about the past, is it? ... How can I tell that the past isn't a fiction designed to account for the discrepancy between my immediate physical sensations and my state of mind?"

- The Ruler of the Universe

On Thu, 24 Aug 2006, Markus Neteler wrote:

On Thu, Aug 24, 2006 at 02:11:12PM +0200, Request Tracker wrote:

this bug's URL: http://intevation.de/rt/webrt?serial_num=5043
-------------------------------------------------------------------------

Subject: r.out.gdal does not export "g.region -p"

Platform: GNU/Linux/x86
grass obtained from: Other (CDROM etc)
grass binary for platform: Downloaded precompiled Binaries
GRASS Version: GRASS 6.0.2 (2006)

r.out.gdal does export the region as defined in "g.region -p", but the full input raster file.

I just found that it is pretty easy to support at least
the current region extent:

This would seem like a good example of why Glynn insisted on retaining r.resample. r.resample to a temporary file and export that would achieve the desired effect (i.e. consistent with other raster export modules) I think? Although would require twice as much disk space. I agree it should be made consistent (i.e. export based on the current region settings).

Paul

Paul Kelly wrote:

>> this bug's URL: http://intevation.de/rt/webrt?serial_num=5043
>> -------------------------------------------------------------------------
>>
>> Subject: r.out.gdal does not export "g.region -p"
>>
>> Platform: GNU/Linux/x86
>> grass obtained from: Other (CDROM etc)
>> grass binary for platform: Downloaded precompiled Binaries
>> GRASS Version: GRASS 6.0.2 (2006)
>>
>>
>> r.out.gdal does export the region as defined in "g.region -p", but the full input raster file.
>
> I just found that it is pretty easy to support at least
> the current region extent:

This would seem like a good example of why Glynn insisted on retaining
r.resample. r.resample to a temporary file and export that would achieve
the desired effect (i.e. consistent with other raster export modules) I
think? Although would require twice as much disk space. I agree it should
be made consistent (i.e. export based on the current region settings).

I would suggest that r.out.gdal should behave like other export
modules and use the current region. If you want "raw" export; you can
always use "g.region rast=..." first.

r.in.* modules are a special case, as you can't use "g.region rast="
before you've imported the raster.

--
Glynn Clements <glynn@gclements.plus.com>

> >> this bug's URL: http://intevation.de/rt/webrt?serial_num=5043
> >------------------------------------------------------------------

..

> >> r.out.gdal does export the region as defined in "g.region -p",
> >> but the full input raster file.

Paul:

> This would seem like a good example of why Glynn insisted on
> retaining r.resample. r.resample to a temporary file and export
> that would achieve the desired effect (i.e. consistent with other
> raster export modules) I think? Although would require twice as
> much disk space. I agree it should be made consistent (i.e. export
> based on the current region settings).

Glynn:

I would suggest that r.out.gdal should behave like other export
modules and use the current region. If you want "raw" export; you can
always use "g.region rast=..." first.

r.in.* modules are a special case, as you can't use "g.region rast="
before you've imported the raster.

Yes, r.out.gdal should act like other raster modules and work from the
current region. But this goes back to r.out.gdal should be a real module
instead of a wrapper script. Then we could do away with the gdal-plugin
dependancy for generic raster output, which I think is a bit of an
unnecessary burden for regular users to have to worry about for expected
functionality.

Frank's comments from some time ago, :wink:
  http://article.gmane.org/gmane.comp.gis.grass.devel/4657

Hamish