Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Given a list of georeferenced rasters, about a hundred, what is the simplest method to generate world files for each?

In this case the source rasters are either geotiff with embedded georeferencing or .BIL with accompanying .PRJ, but the ideal solution shouldn't care what the format is. I'm hoping to avoid duplicating data.

I have at my disposal Arcgis 10 (Arcinfo & Spatial Analyst), GDAL Utilities (gdal v1.8.0), and Quantum GIS 1.8.

share|improve this question
    
generating world files will not always ensure that a software can/does read the world file for georeferencing. Geotiff is what I have had the most luck with in different software. –  Brad Nesom Sep 12 '11 at 17:29
    
are you trying to read EHdr format?? gdal.org/frmt_various.html –  falcacibar Sep 12 '11 at 18:41
1  
the software I'm preparing these for doesn't understand embedded georeferencing or external .prj (proj4 or wkt) files. It only looks at .wld (or .blw, .jpw,... etc.). –  matt wilkie Sep 12 '11 at 19:05

2 Answers 2

up vote 7 down vote accepted

If you're using a recent build of QGIS, you may already have access to the Extract Projection tool mentioned here.

From the article: "What this lets you do is to find out what projection your rasters are in. It then exports this to a .WLD file. It also allows you to create .PRJ files. If you have GDAL Tools installed (and activated), you'll find this new tool under Raster > Projections > Extract Projection."

It includes a batch processing option as well, which is great for your purposes.

share|improve this answer
    
so if I'd waited I day I could have saved myself a couple hours of work! but I wouldn't have learned anything, so I'll call it even. ;-) From reading the commit log, in addition to all the user interface goodness the what this qgis tool does better than mine is handle unicode filenames and writes an external esri-style .prj file. It doesn't do is follow the convention of naming the extension after the input, e.g. for a jpeg it writes .wld rather than .jgw, which may or may not matter to others. Accepting this as the correct answer even though I didn't use it, as it the most complete solution. –  matt wilkie Sep 13 '11 at 16:19

Sparked by Mike Toews pointer to GetGeoTransform, I managed to create a small gdal python script which builds world files for any supported georeferenced raster (I think). The full code is here: gdal-makeworld.py. The essential bits are:

geotransform = dataset.GetGeoTransform()

if geotransform is not None:
    x, x_size, x_rot, y, y_rot, y_size = geotransform
    world_file.write('%s\n' % x_size)
    world_file.write('%s\n' % x_rot)
    world_file.write('%s\n' % y_rot)
    world_file.write('%s\n' % y_size)
    world_file.write('%s\n' % x)
    world_file.write('%s\n' % y)
    world_file.close()

''' geotransform tuple key:
    [0] /* top left x */
    [1] /* w-e pixel resolution */
    [2] /* rotation, 0 if image is "north up" */
    [3] /* top left y */
    [4] /* rotation, 0 if image is "north up" */
    [5] /* n-s pixel resolution */
'''

Additional thanks to Schuyler Erle for writing gdalcopyproj.py which I used as a starting point.

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.