Imagery Processing…Lessons Learned?

Confession: When I studed Geography at George Mason University I only took one class that had anything to do with imagery of any type. Focused around manual interpretation of imagery mostly though we did use ERDAS Imagine once, for a lab.

I could have taken more classes on remote sensing, but I didn’t. My focus was more on cartography and statistical analysis.

Anyway, recently HOT bought some imagery. I naively thought that I could just run it through gdal2tiles.py and go skipping down the road to digitizing. Well, I was wrong.

I received a lot of advice on what to do with the imagery. For example changing it from 16 bit to 8 bit. Which I tried, oddly it worked on one image and not the other. This turns out was just dumb luck that the stretch was almost right when you did that. Other suggestions involved reordering the bands and things such as that. I tried a bunch of different things, none of them worked.

I did discover that if I applied a standard deviation stretch to the imagery in QGIS then it looked right. There wasn’t a way to save this stretch though directly to the GeoTIFF. I did a bunch of searching to see if there was a manual way to do this and I came across this post on using VRTs to add the minimum and maximum of the bands.

So here is my pretty manual way of doing things. Yes I could have done some automation but I figured it was just a couple images.

First I download the image and open it in QGIS. Then I right clicked on the layer and selected properties. In the properties dialog I selected “use standard deviation” and he “apply.” The image should now look like natural color.

Properties Panel QGIS

Next I copied the Red, Green and Blue min/max values.  Now with the correct values the key is to feed them in GDAL correctly. Here you are building a VRT or Virtual Format.  So the actual processing doesn’t take place, you are describing it though.

First step is to stretch each band individually:

gdal_translate -b 1 -scale min max -ot Byte -of VRT your_image.tif 1.vrt

gdal_translate -b 2 -scale min max -ot Byte -of VRT your_image.tif 2.vrt

gdal_translate -b 3 -scale min max -ot Byte -of VRT your_image.tif 3.vrt

Next put the bands back together (virtually):

gdalbuildvrt -separate b123.vrt b1.vrt b2.vrt b3.vrt

Now actually create your GeoTiff

gdal_translate -of gtiff b123.vrt my_beautiful_tif.tif

After that you can tile your tif or do anything else you might want to do with it. In my case I ran gdal2tiles.py

gdal2tiles.py my_beautiful_tif.tif

I suspect there may be a better way of doing things than this.  Though after a lot of researching I didn’t find one.  So this is the process that works for me.  Any suggestions?  Please, please, please leave them in the comments!

December 11, 2011  Tags: , , ,   Posted in: GIS Reference

Leave a Reply