Seeing Earth from Space — from Raw Satellite Data to Beautiful High-resolution Images

In this document, I will describe my workflow for processing free and open Sentinel-2 satellite data into beautiful high-resolution images using free tools.

Tools/Software Used

The tools/software I use here are:

All these great tools are free to use. Please consult the software home pages, your OS package manager, Google, etc. for more information on installing the software. (I carry out the processing in OS X so I am not 100% sure if the processing in Linux or Windows will work in the same way. At least for installing NIK Collection in Linux will probably require use of Windows emulator but there seems to be some tutorials available for doing this.)

Satellite Data

The Sentinel-2 satellite data is free to download and use (before using the data, please see the terms and conditions here) and there are many services that provide the data including:

I usually use Amazon’s service as it has a nice browser for finding images, I do not need to log in, and it is usually faster to download the data than from the official Copernicus service.

The Sentinel-2 data are organized using the Military Grid Reference system. This means Earth’s surface has been divided into a grid and you can/must separately download the data corresponding to each grid square. Later, I will refer these ‘grid squares’ as tiles.

Finding Your Data

In this example, I will show you how to find the data you want to be processed using Amazon’s Sentinel 2 data browser. When you open the Sentinel 2 browser you get a view like this:

In the browser, you can set the Date range and Cloud coverage and browse the map. All tiles that match your date and cloud filters are marked on the map with light green color (note that if you zoom out too far, the browser won’t show you any tiles). If you are looking for very recent data, I would recommend you to set the Date range to something like the last three days (in my experience, the Sentinel data is usually available in this service within 1–2 days from the satellite overpass). You can also filter out very cloudy scenes using the Cloud coverage filter. I typically set the cloud coverage filter to values of about 0–40%.

Sometimes if you are looking for a specific place or city for example it is easier to switch to OpenStreetMap view by clicking on the button on the upper right corner of the view. This view should look something like this:

Lets say I would like to get view of Maputo, the capital of Mozambique. I click on a tile that contains Maputo and it will open a preview/result view in the browser. This time four tiles were found near Maputo.

Next, I find the tile that actually contains Maputo by clicking the results open one by one. Tile 36JVS 2017–01–19 is the correct one:

From the preview I see for example that cloud coverage in this tile is 0%, it contains 97% of data (a part from lower right corner is missing), and it was taken on 19th January 2017 08:57 UTC time. I decide that I want to process the data to construct a true color high-resolution (about 10m x 10m pixel size) image. I click on the link to tile data link to open the Amazon’s data folder containing the actual data. The view now looks like this:

The folder contains the actual data files that are in grayscale JPEG 2000 image format (.jp2) and also some metadata (I am aiming at just getting an image that looks nice so I do not really need the metadata here). Images BXX.jp2 are the data corresponding to different Sentinel 2 bands (wavelengths). Different bands have different resolutions and you can read more about them from ESA’s Sentinel 2 webpage. Bands 4, 3, and 2 correspond to 665nm (red, R), 560 nm (green, G), and 490 nm (blue, B), respectively, so these are the bands I want to use. It is of course possible to construct similarly for example near infrared images but here I just want to make the true color image. In the same folder, you can find an image named TCI.jp2 that is the true color image of the tile. You can use this image as well but I want to fully control the whole process and therefore use the raw band date. Especially with bright surfaces it seems that using raw band data might result in slightly better images than the provided true color image. Now I download the RGB band images (B04.jp2, B03.jp2 and B02.jp2).

From Data to Image

Now I have all the data I need (yes, just those three images) to construct the true color high-resolution image. I open my Terminal and go to the directory that contains these files:

MyComputer:~ $ cd Sentinel2data/20170119Maputo
MyComputer:20170119Maputo $ ls
B02.jp2 B03.jp2 B04.jp2

Next, I use Imagemagick convert tool to combine these red, green, and blue channels into a true color image (if you receive some strange error messages, you most probably just have too old Imagemagick installed, update it to the latest version and everything should work just fine). To do the conversion I run the following command:

MyComputer:20170119Maputo $ convert B04.jp2 B03.jp2 B02.jp2 -combine -colorspace sRGB -level 0,7500 -unsharp 5x2+1+0 -sampling-factor 4:2:2 -quality 98 output.jpg

So what do all these commands mean (I am not 100% sure about all these, but this is what I think they do…):

  • convert is the Imagemagick tool to process images
  • B04.jp2 B03.jp2 B02.jp2 are the input files I give to the program. Giving the images this way will process the whole tile. I usually crop the image later in Gimp but if you would like to crop the image already here using Imagemagick you can replace the input files with: “B04.jpg[WxH+XOFFS+YOFFS] B03.jpg[WxH+XOFFS+YOFFS] B02.jpg[WxH+XOFFS+YOFFS]” where W and H are the width and height of the cropped area, respectively, and XOFFS and YOFFS the coordinates of the upper left corner of the crop position. Example: “B04.jpg[1200x600+4000+0] B03.jpg[1200x600+4000+0] B02.jpg[1200x600+4000+0]” would result in image of size 1200 x 600 pixels and its upper left corner will be pixel (4000,0) of the original tile image.
  • -combine means I want to combine the previously listed grayscale images into one image, by default convert will take the first image as red channel, second as green, and third as blue
  • -colorspace sRGB colorspace of the new image will be sRGB
  • -level 0,7500 this will increase the brightness of the image. Sentinel 2 instruments were designed to image various types of scenes (dark forests and bright deserts for example) and therefore the images can have very wide range of values. This typically results in land scenes that are quite dark and we need to increase the brightness of the image to see anything (without this command the resulting image is probably mostly black). For normal land scenes I usually use this range of 0,7500. For scenes containing very bright features, I try something like 0,9000 for example. If the scene is especially dark, I could try 0,5000. This is a parameter you just need to tune. The brighter the scene, the higher number and the darker the scene the lower number: method of trial and error!
  • -unsharp 5x2+1+0 I like to slightly sharpen the image. In my opinion this will usually make small details look better in the image. For sharpening I use the unsharp mask with parameters 5x2+1+0. These parameters were also found by trying different things. Of course this can be omitted or different parameters could be tried…
  • -sampling-factor 4:2:2 -quality 98 these are just quality parameters for the output JPEG file. Anything could be used but I have found these to be OK for me in most cases.
  • output.jpg name of the output image file

Processing of a whole tile may take a couple of minutes.

Post-processing of image

Cropping the image

I usually crop the image in GIMP. I just open the output.jpg image in GIMP, select the part of the image I want to process further, then select Image -> Crop to selection to crop and save it to a new image, for example outputCrop.jpg.

Adjusting colors, contrasts and details

I do all final adjustments of colors, contrast and details in Color Efex Pro 4 (thanks Google for this great free software!). I usually open the image to be adjusted from Finder (Note: At least to my knowledge it is not possible to ‘save as’ the image after editing and the edited image will overwrite the original one without asking when opened like this. If you want to have a copy of the original image as well, make a copy of it before opening in Color Efex Pro 4):

This is how the Color Efex Pro 4 looks like after opening:

On the left you see all filters you can apply to the photo. In the center you see a preview of the photo after applying the filters. On the right side there is a list of filters already applied (you can add many filters, you can change the ordering of filter by drag-and-drop, etc.) and also a loupe & histogram view that you can use to take a closer look of the image.

After adding and tuning all filters you want to use, you can save them as a recipe with ‘Save Recipe’ button. You can find saved recipes on the left side tabs (you can also import & export recipes there). By clicking saved recipe it will apply the same filters (with saved settings) to the photo. I will now present my recipe I usually use when processing Sentinel images.

My Sentinel 2 recipe I usually use contains the following three filters (I always fine tune the parameters case by case but these are the parameters I start with):

1) Pro contrast

I use Pro contrast to enhance the contrast.

2) Detail extractor

I use Detail extractor to get small details nicely visible and add saturation and tune contrast.

3) Foliage

I use Foliage filter to tune greens/yellows. This is the filter I quite often leave out.

I have created a Github repository for Color Efex Pro 4 filters for satellite images. You can download this filter from there. If you have your own, please consider participating and make a pull request.

Result

And here are the results for this scene:

Original image

After Pro contrast filter

After Detail extractor filter

After Foliage filter

And before sharing the image I add some information and attributions for using Copernicus data.

Here is the final image (full resolution available in Flickr):


Thank you very much for reading, I hope you found this document useful. If you have any questions/improvements/comments/corrections, please let me know, I am happy to answer your questions and hear your ideas. I am also interested in hearing how you carry out the image processing. You can always contact me for example in Twitter.