Average rainfall 2001-2016, global tropics

Map: Average rainfall 2001-2016, global tropics

SMAP map layout and media export

Introduction

This post covers how to define layouts and export media files for data and results from the Soil Moisture Active Passive (SMAP) mission in Karttur’s GeoImagine Framework.

Prerequisites

You must have completed the data processing of SMAP data in the previous post.

SMAP

Project module

The project module file (projSMAP.py) is available in the Project package projects.

Process chain

The project file links to an ASCII text file that contains a list of the xml files to execute. The layout and export processes are under the folder Layout.

projFN ='doc/Layout/smap-layout_YYYYMMDD.txt'

As the path to the project file does not start with a slash “/”, the path is relative to the project module itself. The project package available on Karttur’s GitHub page contains the path and the files required for running the process chain.

Layout

Processing to pleasing looking maps requires that different layout aspects are pre-defined, including:

  • scaling
  • legends
  • palettes
  • movieclock

You must define scaling and palettes. You need legends if you want to add that to your map layouts. You can also define a customized layout of the clock and time line for animations, but you can also use the Framework default.

Scaling

To export a layer to a color map the scaling must be set using the process createscaling. All exported maps are in byte format (valid numerical range between 0 and 255). Thus all compositions that are not defined as byte must be rescaled to fit between 0 and 255. The Framework default is to use 255 to denote nodata and values between 251 and 255 for layout.

Palettes

To set up a palette, use the process addrasterpalette. In the example below three different SMAP related palettes are defined: for soil moisture (vol/vol), for change in soil moisture and for variations in soil moisture.

Create legend

To create legends for use together with maps, use the process createlegend.

Export legend

SMAP palette

With the process exportlegend you can create stand alone legends. To work you must have defined the scaling, the palette and the legend in the previous steps. The process produces three legends, as a Scalable Vector Graphics (.svg file), a .png file and a compressed .jpg file. The svg is saved as a www compliant xml, and you can use it either for editing in a graphics program or inclusion in a web-page (or both).

movieclock

As part of Karttur´s GeoImagine Framework, time series images can be converted to animations with a timeline and a clock showing the year and the season. To create animations you must have installed the terminal apps ImageMagick (for command line image processing) and ffmpeg (for command line movie making). Here are the links to my blog posts on how to install and use ImageMagick and ffmpeg:

The post on ffmpeg also illustrates the use of the GeoImagine Framework movieclock.

Defining a movieclock

An animation requires a pre-defined movieclock (but usually the “default” movieclock is OK), and that the time series data is first exported and then converted to movie frames.

A movieclock object defines the colors, types and sizes of the elements building the clock and timeline in the animation. Basically you do not need to define any of the elements, they are all defaulted. But if you want other postions, widths, margins, colors etc, all can be set using the process addmovieclock.

Export

Exporting layers requires that you have defined the scaling for the composition and a suitable palette. SMAP layers are exported suing the process exporttobytesmap.

Export time series images

If you want to do a movie (animation) of the SMAP time-series data you have to export all the individual SMAP dates. To make the movie look pleasing it is best to export the force filled 16D period time series. Below, both the force filled time series and the seasonal signals are exported, and then used for creating movie animations.

Export seasonal signal

Create movie

To create movie frames, you must first have exported the time-series images. You then convert the individual images to movie frames with the process movieframesmap and then create the clock and timeline with the process movieclocksmap. The latter process also generates the shell scripts for joining the map frames and the clock frames, and for assembling the joined frames to a movie. If you set the parameter asscript to False the scripts are called and executed from within the process.

Create movie frames

By default the process movieframesmap produces a shell script file that you must execute manually to produce the movie frames. The advantage with the script file is that you can edit the area of the map to appear in the movie as well as the embossed watermark text. The link to the script file is reported by the process.

Create movie clock and timeline

The final step before producing the movie (time series animation) is to create the movie clock/timeline that fits with your movie frames. You need to set the dimensions of the movie clock manually as parameters in the process >movieclocksmap. The process uses a combination of python image processing and ImageMagick commands.

The process also produces two shell script files. The first joins (overlays) the movieclock and the image frames (with ImageMagick), and the second produces the movie using ffmpeg. If you do not set the parameter asscript to False you need to execute both scripts manually as reported by the script.

SMAP estimated soil moisture 2015 to 2018 (16 day composites)
Force-filled seasonal (16 day interval) soil moisture from SMAP (average 2015 to 2018)

Resources

ImageMagick for batch processing maps

FFmpeg for map animations