Georeference image files using tiff2geotiff

tiff2geotiff is an application that is provided as part of the VAPOR distribution on all supported platforms. tiff2geotiff can be used to insert geo-referencing as well as date/time stamps into an existing TIFF file. tiff2geotiff can be used to specify geo-referencing for a single image, or for a sequence of images in one multi-directory TIFF file.
Some of the uses of tiff2geotiff include:

  • If you have a terrain image that you would like to map to the terrain in a VAPOR scene, (for example a road map or a political boundary map), you can convert that image to a tiff image and then apply tiff2geotiff to insert geo-referencing that will enable VAPOR to properly map it onto the earth’s surface. Terrain images are available from various web mapping services. For example the URL http://www.nasa.network.com/wms?request=GetMap&version=1.3&layers=|bmng200401&s tyles=default&bbox=-125,25,-64,50&width=1024&height=512&format=image/tiff will return a 1024x512 tiff image of the lon/lat rectangle from (-125,25) to (-64,50). tiff2geotiff can be used to convert this to a geo-referenced terrain image. This is useful on platforms (such as Windows) where the shell command getWMSImage.sh may not work.
  • If you have a sequence of plots (such as produced by NCL or other graphic programs, you can convert these plots to one TIFF file, and specify a date/time stamp and (optionally) a map projection for each plot, so that VAPOR can properly position the images in space and time. This is performed by the NCL script wrf2geotiff.ncl that is described with the VAPOR/NCL analysis page.

When your source image(s) are not TIFF images, you can convert these to a single TIFF image using the convert command available from ImageMagick. Note that VAPOR may not be able to handle all the possible compressions that are available in tiff files, so it is a good idea to use the option “-c none” to tiff2geotiff, or to use “–compress None” as an argument to the convert command.


tiff2geotiff is a modified version of the geo-tiff application geotifcp, and it supports the many options of that program. You can type "tiff2geotiff –h" to see all the command-line options. There are three modes in which tiff2geotiff is useful for inserting geo-reference information into TIFF files for VAPOR visualization:

  1. tiff2geotiff -4 “proj4_string” –n “llx lly urx ury” inputTiffFile outputGeoTiffFile
  2. tiff2geotiff -4 “proj4_string” –m dateLatLonFile inputTiffFile outputGeoTiffFile
  3. tiff2geotiff –M dateFile inputTiffFile outputGeoTiffFile

The first mode is used to insert the same geo-referencing into all images of a tiff file.
The second mode is used to insert time stamps and geo-referencing into each image of a tiff file.
The third mode is used to just insert time stamps into each image of a tiff file.

In the above:

  • Each command converts a TIFF file (inputTiffFile) to a geo-referenced TIFF (geoTiff) file named outputTiffFile. proj4_string is a quoted string that specifies a map projection, as described at the Proj4 wiki. If the source tiff image is a long/lat projection, then the string should be “+proj=latlong +ellps=sphere”, indicating that the map projection is the latitude/longitude projection to a spherical earth. Other projections can be used here; see http://trac.osgeo.org/proj/wiki for Proj4 documentation. The WRF projections supported by VAPOR include Lambert conformal conic, polar stereographic, longitude/latitude, rotated lat/lon, and Mercator.
  • dateLatLonFile is a text file with one line for each image in the input TIFF file. (Note: In TIFF terminology, these images are called “directories”).    Each line is of the form:

Date/Time llx lly urx ury pllx plly purx pury

Where:

  • Date/Time is a WRF-style date/time stamp of the form yyyy-mm-dd_hh:mm:ssllx
  • lly urx ury are the longitude and latitude of the lower-left and upper-right corners of the plot area.
  • pllx plly purx pury are the relative positions of the plot area corners in the full page (values between 0.0 and 1.0, where (0,0) is the lower-left corner of the page and (1,1) is the upper-right corner of the page.
  • dateFile is a text file with one line for each image in the input tiff file. Each line of the file consists of a WRF-style date/time stamp of the form yyyy-mm-dd_hh:mm:ss. llx lly urx ury are the longitude and latitude of the lower-left and upper-right corners of all images in the input TIFF file. They must be enclosed in quotes.
  • Date/Time is a WRF-style date/time stamp of the form yyyy-mm-dd_hh:mm:ss

Examples:

  • Suppose the file “westUS.tiff” is a tiff image of a map of the western US, from latitude 25 to latitude 50, and from longitude -125 to longitude -100. To convert this file to a geo-referenced tiff file “georefWestUS.tiff”, issue the following command (all on one line):

tiff2geotiff -4 “+proj=latlong” –n “-125 25 -100 50” westUS.tiff georefWestUS.tiff

  • Suppose you have a sequence of images in one tiff file “hurricane.tif” that displays a the precipitation from a hurricane as it moves across the Gulf of Mexico. Suppose also that these images are on a lat/lon grid. Create a text file “DatelatlonExtents.txt with one line for each time step. Each line would be like the following, with a date-time stamp followed by 4 longitude/latitude extents, followed by two zeroes and two ones:

2009-09-15_10:00:00 -100 20 -90 30 0 0 1 1