Monday, August 26, 2013

Retaining GeoTiff metadata for an image after editing in Photoshop

Sometimes for whatever reason, we have to edit a GeoTiff image in a photo manipulation software application like Photoshop. These image editing applications usually do not retain the geo-referencing information of the GeoTiff file after editing. The following screenshots show a GeoTiff image being edited in GIMP to remove some text from the image.

When the edited file is opened in a mapping software application e.g. Global Mapper, the software will be unable to detect any geo-referencing information, as shown below.


There is a way to apply back the geo-referencing information from the original GeoTiff file. As long as the edited image pixel sizes (width and height) remain the same as the original GeoTiff image, we can copy the GeoTiff metadata from the original file to the edited file using the listgeo and geotifcp executables. These programs can be downloaded as part of FWTools.

The following shows how to use the listgeo and geotifcp executables.

  1. Open up a command prompt. Type in the following:

    C:\> listgeo -no_norm original.tif > metadata.geo

    The GeoTiff file's geo-referencing metadata is copied out from the input original.tif and written to the output file metadata.geo.
  2. Next, type in the following:

    C:\> geotifcp -g metadata.geo edited.tif output.tif

    The geo-referencing info in the metadata.geo file is applied to the edited.tif file and written out to output.tif.  When the output.tif file is loaded in a mapping application, the image is placed in the correct geographic location.


2 comments:

boripr said...

Thank you thank you thank you...

ArtPlant said...

Or you can use free QGIS 3.x for that. Open menu "Processing", choose Toolbox. In "Processing Toolbox", find GDAL, choose Raster conversion and choose option Translate. Window appear - choose your geotiff and under Advanced parameters, hit + sign to add command. Under Name enter word tfw, under Value enter yes. Specify output destination, name of the file and voila ... your geotiff file is converted to plain tiff and tfw part. Now you can edit tiff in image editor of your choice and has it geolocated as long as you don't change number of pixels in x or y axis.