Select to view content in your preferred language

Programmatically georeference raster from other raster

1562
4
07-04-2011 05:26 AM
HansLiu
New Contributor
I have the following task:

I have a georeferenced (Geo-)Tiff file, a.tif. Using an external program, I create another plain (no georeferencing data) TIFF file b.tif. (Imagine say that I open a.tif in Photoshop, apply a motion blur to the whole image, and save the result as b.tif, but in such a way that the georeferencing metadata is lost.)

Now, b.tif and a.tif represent the same region on the globe using exactly the same projection. a.tif carries information about where this region is, but b.tif does not; I want to copy that information from a.tif to b.tif. Or in other words, I want to alter b.tif so that it is perfectly aligned on top of a.tif if I open them both in ArcMap. I need to do this from a Python script.

a.tif and b.tif will have the same width and height (in pixels), but not necessarily the same color depth.

This seems like it should be a simple task with ArcGIS scripting, but I can't figure out how to do this. I think I can copy the projection data by using DefineProjection_management(), but as far as I can tell, this only changes the projection and not the actual position of the image within the projection's coordinate system.

I am using version 10 of ArcGIS.

Any help would be much appreciated.
Tags (2)
0 Kudos
4 Replies
MartinScheiber
Deactivated User
Hey Hans,

I have a similar problem as you do/did.
Did you ever find a solution for that ??

Cheers,
Martin
0 Kudos
GerryGabrisch
Frequent Contributor
If a.tif is georeferenced there should be a a.twf (world file) associated with it.  If b.tif has the same cell size and extent you can save a.twf as a new file b.twf in the same location as b.tif.

Then use shutil to copy the file....
import shutil
shutil.copyfile(r"C:\gtemp\a.tfw", r"C:\gtemp\aa.tfw")
0 Kudos
HansLiu
New Contributor
Martin:

I never did find a way to do it using ArcGIS scripting. Instead, I used the tools listgeo and geotifcp from the GeoTIFF library, which solved the problem in a simple way.
0 Kudos
MartinScheiber
Deactivated User
Gerry, Hans,

thanks for your tips. I´ll give it a try.

Martin
0 Kudos