map colours onto data values in GDAL

This is a quick post originating from a discussion I had recently. Sometimes GIS data does not come with it’s original colour map but only as raw numbers. These raw numbers (classes) are fine for calculations, but rather limit the way you visualize things. Here, I’ll show how to map colours to the classes or ranges using the Geospatial Data Abstraction Library (GDAL).

All you need is a list of classes which you want to map to particular colours. The format of this colour table is rather flexible and is described in full on the GRASS r.colors page. For this particular example I used the colours of the 0.5 km MODIS-based Global Land Cover Climatology map, which translates into a table with 16 classes (I attached the table at the end of the blog post). You can download the data form the USGS website if you want to try this example (warning: large file - 4GB unzipped).

 

global_veg

# If the colour table is saved in colours.csv the following
# command links a proper colour table to a geotiff file
# without this information.
gdaldem color-relief input.tif colours.csv output.tif

The above command might map the colours to the classes but the map still remains rather static. If you want to create a Google Earth compatible file (mapped onto a 3D sphere), you can do so by translating the file format. The resulting KML file should open in Google Earth if you have a copy running.

gdal_translate -of KMLSUPEROVERLAY input.tif output.kml -co format=png

The full colour table for the image as linked to above is shown below.

0 186 254 253
1 0 100 1
2 77 165 87
3 125 204 15
4 98 232 101
5 55 198 132
6 214 119 117
7 253 237 160
8 185 231 141
9 255 224 27
10 254 192 107
11 37 138 220
12 252 251 0
13 251 3 4
14 147 144 5
15 254 220 211
16 191 191 191

 

 

Harvard 360

I’m starting a new series of blog posts called Harvard 360 (a bit of my life and research on the Harvard campus). I’ll be posting 360 immersive pictures to provide a real feel for my work around Harvard University, and in particular during field work.

I kick off the series with an image of Harvard Yard. Harvard Yard houses the oldest buildings on campus as well as all undergraduate housing and several libraries. In front of the white building in the distance is the statue of John Harvard. [click the grey bar to load the image if not loading automatically, or click the link to access the VR Flickr page]

Life cycle events and weather in the tropics (DR Congo)

Life cycle events in tropical forests, like their more temperate counterparts, are in part tuned to changes in the weather throughout the year. Unlike the more temperate regions the temperature in the tropics is not the main driver of phenology, as it stays more or less stable throughout the year. Below you see a summary graph of the temperature of Kisangani (120 km to the east of Yangambi), which averages around a ~25C or rather perfect growing conditions.

However, the region and most of the basin goes through two wet seasons. This is due to the fact that the intertropical convergence zone (ITCZ), a band of clouds and thunderstorms, moves back and forth across the equator following the sun’s zenith point. Given the location of the Congo Basin around the equator the ITCZ passes over the basin two times a year, due to tilt in the Earth’s axis, creating two rainy seasons. In the bar graph below you see the monthly totals, where values over 150mm are considered “wet” months.

If you compare an example of life cycle events of some of the intermediate Jungle Rhythm results you see that this particular tree flowers at the start of the wet season, while leaf senescence starts at the end of the dry season. Not all trees will show this pattern, as different species might take different environmental cues (which are or are not met depending on the seasonal changes or yearly variability). However, the example illustrates the relation between weather and life cycle events very clearly. The importance of these seasonal changes in the tropics can not be understated. A recent study also linked these seasonal changes to measurable differences in CO2 uptake from the atmosphere, a main incentive for me to document these life cycle changes in the Jungle Rhythms project.

first_processing_results_graph

My Nature Climate Change grassland study is online!

My latest paper titled “Productivity of North American grasslands is increased under future climate scenarios despite rising aridity”, in Nature Climate Change, is finally online. After 1.5 year of work I’m rather pleased to see it “in press” !

The short version of the paper reads:

  1. Grasses will adapt to a more arid world by shifting their growing season
  2. This leads, counter-intuitively, to a slight increase in ecosystem productivity
  3. However, at the same time this puts rangeland managers at a disadvantage due to this more variable growing season.

You can read the full version HERE if you have access to the Nature publishing group content. Alternatively, you can find a full copy on Research Gate (or email me).

Some popular press coverage can be found here:

http://scienceblog.com/483100/in-grasslands-longer-spring-growing-season-offsets-higher-summer-temperatures/

 

 

(header image courtesy of Russ Scott)

Pagination


© 2018. All rights reserved.

Powered by Hydejack v7.5.1