A common method for creating raster data that can be ingested into a GIS system, is to encode the data into a GeoTIFF. A GeoTIFF is a TIFF image file, with geographic tags that allow the image to have a geographic presence.
In this tutorial we will cover:
1. Creating a TIFF from a bitmap using libtiff.
2. Creating metadata and a world file for the GeoTIFF using libgeotiff.
3. Encoding the TIFF and metadata to make the GeoTIFF using libgeotiff.
4. Checking the correctness of the GeoTIFF.
Red Hat Linux 3.2.3-58
GNU Make version 3.79.1
gcc version 3.2.3
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Apache Tomcat 6.0.14
Go ahead and download the latest version of libtiff. Libtiff is a library that allows manipulation of TIFFS and is required for the use of libgeotiff. Below are cursory commands for installation, commands may vary depending on environment:
Download the latest version of libgeotiff. Libgeotiff is a library that allows manipulation of GeoTIFFS. Below are cursory commands for installation, commands may vary depending on environment:
4/12 A World Map:
GeoTIFF of the NASA Blue Marble. I made this using gdalwarp from one of the .ecws from NASA’s Blue Marble website. Great high level map, works fine for the weather applications I created it for. However, when you begin to zoom in, the image becomes pixelated. Perhaps we want some areas with more clarity, without having fine grain detail in the whole image.
5/12 A Detailed Area of Interest:
Santa Rosa Island off of Santa Barbara in California. This image is a screen shot from the OpenAerielMap website. Convert the bitmap to a TIFF. I would generally do this in Java with JAI, but we might as well use what we just compiled from libtiff:
We have all the tools we need, and we have all of our sources files. Our goal is to take the TIFF we just made from a bitmap, and to geographically encode it, such that it can be overlaid on our Blue Marble to allow extra information for the area of interest.
We can see all of the geospatial information that we need is already available.
The .tfw world file is a simple file that holds coordinate information for the GeoTIFF.
Line 1: A, pixel size in the x-direction in map units/pixel
Line 2: D: rotation about y-axis
Line 3: B: rotation about x-axis
Line 4: E: pixel size in the y-direction in map units, almost always negative
Line 5: C: x-coordinate of the center of the upper left pixel
Line 6: F: y-coordinate of the center of the upper left pixel
Line 2 and 3 can be zero, as there is going to be no rotation:
Using Google Earth, we can extrapolate the top left corner's coordinates. Using the highly scientificly accurate method of 'eyeballing', we compare Google Earth's Channel Island image, with what we think is the location of the top left corner of our TIFF. Zooming in to a comparable level of the GeoTIFF, as well as opening it and placing it on top of Google Earth itself often helps in this process. I've guessed it out to about 34.143 N 120.530 W.
The width in pixels is: 1096, the height in pixels is: 724.
The width of the GeoTIFF will have the right edge at ~-119.7273170376
120.5301720000 - 119.7273170376 = 1096 * Y
0.8028549624/1096 = Y
0.0007325319 = Y
The height of the GeoTIFF will have the bottom edge at ~33.6912860376
33.6912860376 - 34.1439110000 = 724 * X
-0.4526249624/724 = X
-0.0006251726 = X
9/12 Produce the GeoTIFF Using geotifcp:
At this point one might wonder about the information in the metadata file that appears to make the world file moot. For the purpose of this tutorial I've used both files so that the reader can get an understanding of both. Geotifcp will allow the worldfile's tie point and scale information to take precedence.
Everything seems to work as expected. Our new GeoTIFF is responding with the proper information.
11/12 Really Confirm:
Installation of Tomcat/GeoServer is beyond the scope of this article, but is well documented on their respective web pages.
a) Add bluemarble.tif as a coverage data store.
b) Add santarosageo.tif as a coverage data store.
c) Create a layer group with santarosageo.tif on top.
I'd love to show you some nice OpenLayers maps, however, my hosting package doesn't allow me to run GeoServer, and I'm not paying $50.00 a month just to drop a .war.
So take a look at the screenshots below:
The above screen shots are zoomed in our area of interest, our GeoTIFF is exactly where we expect it to be, with proper dimensions.
a) Mosaic together the two files.
b) Properly integrate them into a single GeoTIFF.
c) Have the high resolution image only show up at a specific zoom level in the OpenLayers application.