Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
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

4 Answers

up vote 1 down vote accepted

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 :).

share|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 at 13:57

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

share|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

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.

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

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
b.save("C:\new_extent.tif")

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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