I have many (10k) raster files, all with identical size and pixel dimensions, which need to be georeferenced. I would like to georeference one of them manually, using either QGIS or GRASS, and then apply the same spatial reference to all the others. This seems like it should be a simple task. Is there some command-line utility that I could script to loop over all the files, or is there something in GRASS that will do this?

  • a simple .bat file would be able to do this if all images are identical in size and pixel dimensions. create a csv stackoverflow.com/questions/14902818/… – Mapperz Mar 19 '13 at 15:39
  • 1
    Are you talking about the definition of the spatial reference (same for each raster) or the world files (nearly the same by means of pixel dimension and size, but not by insertion coordinate)? Do the filenames contain the insertion coordinate implicitely? How are the files named? – Jürgen Zornig Mar 19 '13 at 15:59
  • @JürgenZornig: I'm not sure that I understand your question, but I'll attempt to answer nonetheless. The rasters represent a time series for a single geographic area. Their size and pixel dimensions are identical and they have a perfect pixel-to-pixel correspondance (only the HSV varies), so they should share a common georeference. The filenames represent only where the images belong in the time series; the georeference must be established visually (rather arbitrarily, actually). – Gregory Mar 19 '13 at 16:20
  • ah ok, I thought you are talking about tiles, where each tile covers another geographic area. Knowing that, Dango's answer is completely right. I would do this with some simple DOS shell commands and a little Batch scripting. Not very elegant, but efficient. Use "dir /b *.tif > list.txt" to get a list of all filenames, import it in Excel, extend it with the copy commands to copy the manually created georeference to each raster file, save this as .bat and execute it... – Jürgen Zornig Mar 19 '13 at 16:30

GDAL tool gdal_edit.py http://www.gdal.org/gdal_edit.html is what you are searching for. You need to use -a_srs parameter and depending on your images and how you georeference the first image either -ullr or a few -gcp parameters.


Maybe you could create a world file for the manullay georeferenced raster and then change the name of the file to suit the other rasters.

  • This will only work if all rasters share the same coordinate. In a world file, you have to modify the coordinate corresponding to each raster also. – Jürgen Zornig Mar 19 '13 at 15:54

Assuming all raster files have the same projection, you could define a GRASS location using one of the raster files and then import the others forcing them to take on the same projection information. In GRASS, if you put all your files in one folder, you can run

for i in *.tif; do
  r.in.gdal -o input=$i output=${i%%.tif} 

Replace tif with the appropriate extension.

You can also do this outside of grass using gdalwarp if you just want assign a projection to the raster files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.