I've got some GeoTIFF files that have wrong bounding box extent and wrong CRS associated to.

Fortunately I know the right CRS, but even associating it to the files (I've tried both with QGIS and ArcCatalog) their extent remains the wrong one.

So I was wondering if there's a way to completely erase the GeoTIFF header file, then assigning the CRS and obtaining the correct bounding box.

  • Thanks to all the people that answered my question. I'm aware about gdal_translate as the correct solution for this problem (thanks @garrett-hall), but as I've explained it's complex and time consuming when dealing with a great number of files. Maybe a raster managing plugin e.g. for QGIS would be an easy and comfortable solution. I've solved this issue converting the files from TIFF to PNG and back to TIFF (as suggested by @dango). Strangely the reconverted TIFF had right extent and pixel size, so I've assigned it the correct CRS. – Ira Jun 21 '12 at 18:08
  • this NumPyArrayToRaster is a great solution for Arc folks! Totally worked for me – ABedogne Jan 12 '18 at 15:54
  • Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review – Mark Ireland Jan 12 '18 at 16:14

Try converting them to another format, if you convert them to a PNG for example the headers will not be stored on the image but in a separate file. These can then be deleted before converting the pngs back to tiff. Might want to think about what format you use so you don't lost information along the way. I've done this a few times with veal_translate but of course arc will be able to Handel it to :).

| improve this answer | |
  • A great option for this is to use IrfanView (Windows). I just converted over a hundred TIFs to PNG back and forth. This program is a great viewer as well, but the conversion options were many. – Elliott Apr 24 '13 at 13:57

Building on Garrett Hall suggestion, you can use gdal_translate, and a GeoTIFF format specific setting that prevents GDAL from writing any GeoTIFF tags to the output file. If the georeferencing information is stored externally to the original file as a world file then it can be easily applied to the new corrected TIF.

This assumes that you have QGIS installed and is written from a MS Windows standpoint:

  1. Open a OSGeo4W command prompt - this should be found under the Quantum GIS start menu folder with a shortcut called 'OSGeo4W'
  2. Enter the following command at the prompt. You can copy and paste, but note that the Ctrl+v shortcut doesn't work on the command prompt, you have to right click instead.

    gdal_translate -co PROFILE=BASELINE ProblematicTIF CorrectedTIF

Replacing ProblematicTIF with the full path to your problematic TIF file, enclosed in double quotes, and CorrectedTIF with the full path to the corrected file that will be created, again in double quotes (there's no option to overwrite with this method unfortunately, a new file has to be created).

An example would be:

gdal_translate -co PROFILE=BASELINE "C:\GeoRefencing\Highfield_Campus.tif" "C:\GeoRefencing\Highfield_Campus_corrected.tif"
| improve this answer | |

To expand on @Garrett Hall's answer, gdal_translate is indeed what you need. Something like this should work:

gdal_translate -a_srs <CRS> -a_ullr <xmin> <ymax> <xmax> <ymin> src.tif dest.tif

Where <CRS> should be something like EPSG:27700 and <xmin> <ymax> <xmax> <ymin> should be the known extents of your image.

| improve this answer | |
  • Please see my comment on Garrett's answer. – Ira Jun 21 '12 at 17:51

I believe you can use gdal_translate and set the bounding box using the -a_ullr argument.

| improve this answer | |
  • Yes, I could, but it's a really complicated and time consuming process because I have to infer upper left and lower left coordinates of each file (they're several tens). – Ira Jun 21 '12 at 17:24
  • 2
    The bit that got both Garrett and me was that you said you wanted to obtain the correct bounding box. Well once you stripped any metadata from the image, there's no way of automatically knowing where the image is located in the world. If it's only several tens, and you only need to do it once, a short bash/DOS/Python script will do the job. – MerseyViking Jun 21 '12 at 18:03
  • I have the world file of each raster, with pixel resolution in map units, coords of lower left pixel and rototraslation parameters, so it's easy to rebuild the geometry of each file. Moreover, I've converted all GeoTIFFs to PNG and back to GeoTIFF and strangely the metadata of all files had the right extent as well as the right pixel resolution (that in the original rasters was wrong). – Ira Jun 22 '12 at 8:13

I think Garrett Hall's suggestion of using gdal_translate is probably the quickest and easiest solution. However, you can also read your data into a numpy array and write it back out in tiff format with the proper extent. Using arcpy it might look like:

import arcpy
a = arcpy.RasterToNumPyArray("C:\old_extent.tif")
b = arcpy.NumPyArrayToRaster(a, arcpy.Point(x, y)) #x and y are your new lower left coordinates

| improve this answer | |

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.