7

I am having trouble getting geotiff rasters to get correctly placed even with a world file available. I have tracked down some discussion from 2010 that suggests that if the geotiff already has the registration in the header, QGIS will ignore the world file. It looks like the problem is that the geotiff header states the location is Unknown. Since it is stated, QGIS then ignores the world file with the correct information in it. I thought the purpose of a world file was to that priority over the geotiff header to correct mistakes like this. If this is the case, shouldn't the code be changed?

So in the meantime, does anyone have a work-around?

1
  • In addition to the points made below (gdal ignoring world files if some geo tags are present, gdal/esri disagreeing on pixel edge/centre references), there's no naming standard for world files. Check you're using one that gdal knows about, and avoid using them in the future if you can. I've seen tifw, tiffw, tfw, wld, tiff.wld, …
    – scruss
    Commented Dec 10, 2014 at 13:14

5 Answers 5

5

The use of world files pre-dates GeoTiff, I can remember using World Tiff images in the 90's back when JPEG was a new and misunderstood format, there was no GeoTiff, I can't remember the exact year but it would have been around 2002 when I first heard of software using the 'new' format that didn't need a world file. Some software still doesn't support GeoTiff and needs the world file.

Whether the world file is supposed to supersede the GeoTags or not in my experience software reads the internal georeference and only if it is missing the tags does it go looking for a world file. If the file is tagged as 'unknown' then most software stops trying to locate it and does't even look for a world file.

This happens occasionally, the Geo tags and world get mucked up and the world gets ignored. You can 'break' the georeference by editing and saving with Photoshop/GIMP/others (which doesn't write geo tags) or update with GeoTiff Examiner which will show you both and you can decide which is right, then copy one to the other.

If you have to do a lot of them a method that has worked for me previously is to convert to windows bitmap (no geo tags) using IView (IrfanView) in batch mode then copy the tfw and rename to bpw in DOS.

Alternately convert on batch using IView in batch GeoTiff->Bitmap then batch Bitmap->Tiff, copy the world files from the original into the new folder if you're not keen on renaming in DOS or using Geo-Bitmap.

Existing Georeference can cause problems when registering (georeferencing) images a 2nd time: if an image is already geolocated and then georeference is attempted again unexpected results can occur ranging from being unable to overwrite to the image being stretched all the way around the Earth.

0
4

GDAL is the software component used by QGIS to open rasters. The georeferencing data is normally embedded in the GeoTIFF file, however (from GTiff):

If no georeferencing information is available in the TIFF file itself, GDAL will also check for, and use an ESRI world file with the extension .tfw

Essentially GDAL is only using the georeference data from the GeoTIFF file, and ignoring the secondary information supplied in the world file.

Here's what I suggest you do. Install the geotiff utilities (e.g., if you have OSGeo4W, install libgeotiff; if you have Ubuntu, install geotiff-bin, etc.), and use the geotifcp utility to install positioning info from ESRI Worldfile into a new GeoTIFF file.

For example, if you have myraster.tif and myraster.tfw:

geotifcp -e myraster.tfw  myraster.tif newraster.tif

The updated raster file is newraster.tif. You could also mv newraster.tif myraster.tif if you only want one file to work with.

There are other ways to modify this data with Python, if you are interested.

Also, be aware that GDAL has a georeference to the pixel corner (usually the upper left), but the ESRI Worldfile has a georeference to the pixel centre. So the half-resolution needs to be translated to convert between the two affine transform conventions.

2
  • Try the GeoTiff examiner Mike. We use it to 'bank' the georeference before editing in Photoshop. It's a really cute GUI; All you do is hit one arrow to copy parameters from/to the world file then hit 'update'. Some persons may find the GUI friendlier than command line. Commented Dec 10, 2014 at 5:05
  • Thank you all for your responses. They are very useful leads. Bob Commented Dec 10, 2014 at 18:16
2

You should add exact info about the current situation to the question. Such info can be obtained from the gdalinfo report http://www.gdal.org/gdalinfo.html, from the image layer properties that QGIS is listing (Layer properties - Metadata - Properties) or by listing the GeoTIFF tags with the listgeo utility http://www.remotesensing.org/geotiff/listgeo.html.

I mention two more options for fixing the georeferencing with GDAL tools:

  1. Use gdal_edit.py http://www.gdal.org/gdal_edit.html and set the correct bounds with option -a_ullr ulx uly lrx lry: Assign/override the georeferenced bounds of the dataset.
  2. Make a clean copy of the image without GeoTIFF tags with gdal_translate and continue by editing manually the .tfw file which is now the only means for georeferencing. The command to use is

gdal_translate -of GTiff -co TFW=YES -co PROFILE=BASELINE image_in.tif clean_out.tif

1
  • 1
    Also gdal_edit.py -unsetgt will give precedence to the world file.
    – Mike T
    Commented Dec 15, 2014 at 19:54
0

I know this question is little old but the latest GDAL v2. 2+ has its answer.

Every raster file is associated with georeferencing information which is used by GIS applications. This georeferencing information may be in the form of PAM (Persistent Auxiliary metadata) .aux.xml sidecar file, INTERNAL, TABFILE (.tab) or WORLDFILE.

By default GDAL uses one of these forms in the priority order as mentioned above. This priority order can be changed (from GDAL v2.2+) with the GDAL_GEOREF_SOURCES configuration option (or GEOREF_SOURCES open option) whose value is a comma-separated list of the following keywords : PAM,INTERNAL,TABFILE,WORLDFILE,NONE. First mentioned sources are the most priority over the next ones. A non mentioned source will be ignored.

For example set Environmental variable GDAL_GEOREF_SOURCES and value as WORLDFILE,PAM,INTERNAL,TABFILE,NONE for giving first priority to Worldfile.

For more information visit GDAL geotiff.

-1

I'm having the same issue. My images get placed correctly with tfw files in autocad (raster design), I've tried redoing tfw files. It's ~40 images, of which something like 8-10 are not in the correct spot. They're all the same size, weight, type, and tfw look the same. Ofc, not identical numbers, but look the same.I'm outta my wits here!

EDIT: 5 minutes later.. I've gone and done the variable thingie, but didn't restart qgis before writing. Aaaand now i get a message on thansformations, but it loads all the images in the correct place. Thank you!

2
  • Welcome to GIS SE. As a new user, please take the Tour for a better idea of how our Focused question/Best answer model operates. We are not a discussion forum. You've left a comment in an "Answer" box, with a follow-up comment invalidating it as an edit. Since this is a comment, it will likely be deleted by automated review. Please ask only questions in Questions and provide only answers in Answers. It takes some time to build up sufficient reputation to comment.
    – Vince
    Commented May 10, 2023 at 14:07
  • No problems!Thank you:)
    – IggyThePop
    Commented May 11, 2023 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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