27 May 2015
I’ve had my eyes on schooner-tk for a while now. I don’t remember how I came across it, but it probably has something to do with @btjakes. Anyways, it looks like a useful library, let’s take a look at what it can do.
As usual, I’m going to assume you’re working on OSX and are comfortable with the command line for this tutorial.
From the README:
Schooner-tk is a collection of utilities for averaging, color correcting,
and removing artifacts from satellite images. It complements the GDAL
utilities and the wonderful landsat util.
Schooner-tk currently consists of 5 utilities:
- schooner-blend averages multiple datasets together on a per pixel basis in order to remove temporary artifacts such as small clouds, airplane contrails, and sensor malfunctions.
- schooner-cloud tool creates a cloud and snow mask from a landsat 8 quality assessment band.
- schooner-contrast attempts to automatically color correct a landsat image.
- schooner-multibalance automatically corrects each band of many datasets so that each dataset has a similar color profile. This is useful as a preprocessing step to schooner-blend.
- schooner-stitch allows you to seamlessly stitch multiple images together.
Schooner requires OpenCV 3, which Homebrew doesn’t install by default. Make sure you get the correct version by running the following:
brew install opencv --devel --without-opencl brew info opencv
From there, we can install Schooner with:
git clone email@example.com:jacquestardie/schooner-tk.git cd schooner-tk/src make
We’re going to need some data; Landsat-util is the fastest way to get it. I’ll be working with scenes from Landsat 8 taken over Northern Maine.
pip install landsat-util landsat download LC80110272014262LGN00 LC80100272014255LGN00
Your data will be downloaded to the
~/landsat directory on your machine.
Stitching scenes together
I created color infrared (543) composites of our two scenes. They’re great, but they’re separate, and that’s not what I want.
Let’s use Schooner to stitch them together:
./schooner-stitch \ ~/landsat/processed/LC80100272014255LGN00/LC80100272014255LGN00_bands_543.TIF \ ~/landsat/processed/LC80110272014262LGN00/LC80110272014262LGN00_bands_543.TIF \ ~/Desktop/543-stitched.tif
But will it blend?
So we can easily stitch images together that are adjacent to one another, but what if we want to combine a stack of scenes together that all have the same boundaries? Depth, instead of width?
Landsat-util provides a handy
-p flag to the
download parameter that automatically builds a composite for you. By default, it builds a Natural color (432) composite. We’ll take 3 scenes, and see what they look like averaged together.
landsat download -p LC80100272014255LGN00 landsat download -p LC80100272014223LGN00 landsat download -p LC80100272013236LGN00
I’m not sure what’s happening with that last composite, but it’s way too dark and is going to affect our blended image significantly so let’s fix the color contrast first.
./schooner-contrast \ ~/landsat/processed/LC80100272013236LGN00/LC80100272013236LGN00_bands_432.TIF \ improve-the-contrast.tif
Now that we have the necessary data, we can use
./schooner-blend \ ~/landsat/processed/LC80100272014255LGN00/LC80100272014255LGN00_bands_432.TIF \ ~/landsat/processed/LC80100272014223LGN00/LC80100272014223LGN00_bands_432.TIF \ improve-the-contrast.tif \ blend.tif
Honestly, the blended image isn’t particularly useful, but I think you can see how finding the average pixel values could be useful.