Step Up Your Raster Handling Skills

It is not uncommon for raster data to be large and unruly. Creating tiles is one way to deal with these large datasets and speed up rendering. This post introduces a few handy tools for dealing with raster data while walking through the process of combining multiple raster files to create tiles for a super-overlay for a nice clean visual output that renders more efficiently (particularly in Google Earth). All from the command line.

For this example, I have a number of jpg images that have large amount of white area that was not recognized as nodata, which can be seen by adding the imagery over a satellite image. Furthermore, when creating a vrt a black nodata bounding box is created around the extent of the combined images. You can see both in the image below. We want to hide both sets of no data before we create the tiles for the super-overlay.

What you’ll need:

Step 1: Create a vrt

gdalbuildvrt -srcnodata 255 -vrtnodata 0 /AllImages.vrt  /Images/*.jpg

The vrt (virtual dataset) in our case is allowing us to reference a number of datasets to treat and view them as one. –srcnodata 255 sets cells with the value of 255 (white) as the source’s nodata and –vrtnodata 0 sets black, created by building a vrt, as nodata as well. /AllImages.vrt is your output. /Images/*.jpg is your input. The *.jpg makes sure all jpg files in the images folder are added to the vrt. Now all nodata values will be transparent. Hooray.

Step 2: Create those tiles! -p geodetic -k Desktop/TestImages.vrt

Tiles speed up rendering by creating tiles of various resolutions and only displays tiles that are ‘in view’. Lower resolution tiles are displayed when viewing data zoomed out and higher resolution tiles as you zoom in. –p geodetic sets the profile of the data -k forces the creation of the KML for the super-overlay.

Step 3: View your super-overlay in Google Earth

Open up the doc.kml file that was created and check out you sweet output in Google Earth. Google Earth drapes the imagery over to topography making your raster images 3D. Pretty slick.