[GRASS-user] r.region

Hamish hamish_nospam at yahoo.com
Tue Jul 3 22:01:22 EDT 2007


Maciej Sieczka wrote:

> goldneaa wrote:
> > If I have about 800 raster files in tiff format that are in the
> > wrong projection.  Is there a way to change their coordinate systems
> > all at once.  After examining r.region it seems to only want to
> > change one raster at a time.  Will I have to build a command in
> > unix, in order to change these rasters projections?
> 
> r.region is not for changing raster's projection. It only moves and
> rescales it in space, by setting "the boundary definitions for a
> raster map".
> 
> If you want to reproject, use r.proj instead.
> 
> As to multiple raster input - in shell you could use something like:
> 
> for i in `g.list rast mapset=some_mapset | grep string_common_for_all_rasters_you_want_included`
> do
>  r.some.command input=${i} output=${i}_suffix
> done
> 
> Mind that g.list always prints a few extra lines of text at the top
> and the bottom of it's output,
..
> BTW - it would be really nice IMHO to have a "Print in shell script
> style" option in g.list, ie. no extra text, one name per line.


Use g.mlist.


for MAP in `g.mlist rast` ; do
  r.info -r $MAP
done


Michael Perdue wrote:
> The simplest way to reproject a bunch of tiff files into a new  
> projection is to use gdalwarp in a loop. Something like,
>
> for i in `ls *.tif |   [...]

beware that the max command line string may be 4096 chars, and 800 maps
could fill that. ("basename $file .tif" in the `command` part could help
conserve 4 chars per map)


back to the original question:
> If I have about 800 raster files in tiff format that are in the wrong
> projection.  Is there a way to change their coordinate systems all at  
> once.

As the input is TIFF, probably the easy way is to use GDAL tools,
specifically gdalwarp and/or gdal_translate to make a new GeoTIFF in the
target projection.


Hamish




More information about the grass-user mailing list