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?
Thanks
Aaron
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 | awk 'BEGIN {FS="."} ; {print $1} '
; do
gdalwarp s_srs epsg:26910 t_srs epsg:2766 $i.tif $i_spcs-CaliforniaZone1.tif
done
You’ll have to play with the syntax as I don’t use it very often but this example should transform all the tiff files in the local directory from epsg:26910 (NAD83 UTM10) to epsg:2766 (SPCS NAD83 California zone 1).
Cheers,
Mike
On 3-Jul-07, at 3:11 PM, goldneaa@onid.orst.edu 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?
Thanks
Aaron
grassuser mailing list
grassuser@grass.itc.it
http://grass.itc.it/mailman/listinfo/grassuser
goldneaa@onid.orst.edu 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, which you have to watch out for when
grep'ping for a string. You can filter them out with:
g.list rast mapset=some_mapset | grep -v "files available in
mapset\|----------------------------------------------"
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.
Maciek
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
doneMind 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
Hamish wrote:
Maciej Sieczka wrote:
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
Right. Thanks Hamish.
Maciek