Introduction
Layout and symbolization is an integral part of mapping. This article demonstrate how to set color ramps, add hill shade and export raster layers as images with legends. The example used in the article is elevation data over the Norwegian coastline. The export does not include any graticule, scale or north arrow. How to add these geographic features and turn the image to a map is covered in another article. Not yet done.
Prerequisites
You must have Karttur’s complete GeoImagine Framework installed as described in the post Install and setup spatial data IDE. You must also have a Digital Elevation Model (DEM) imported to the Framework.
Export procedure
Exports to layout in the Framework is always done to byte binary images with numerical cell values in the range 0-255. Value in the range 251-255 are reserved for special layouts, where 255 is always used to represent null (no data). Export do not need to use the full range 0 to 250 to represent the layer content.
The scaling to binary range (defined by the process CreateScaling) is tied to each composition and can not be defined as part of the export processes. Also the Legend layout, defined using the process CreateLegend is linked to the composition and can not be changed. The color ramp, defined using the Framework process AddRasterPalette is defined independently of the composition. To actually use a particular color ramp with a particular composition, the legend must be exported by the process ExportLegend. The exception is when you want to apply a color ramp while dynamically setting the min-max range of actual pixel values, then the legend is exported on the fly.
To set the color ramp dynamically you set the parameter minmax in the process ExportTilesToByte to true. You can then define values for min (srcmin) and max (srcmin) values, or let the Framework examine the min and max, but that will then always refer to the entire tile (not any part used for the image map).
Process chain
To create an image map with a legend you must have setup and run the following Framework processes:
- CreateScaling
- AddRasterPalette
- CreateLegend
- ExportLegend
CreateScaling
Elevation data can range from approximately -415 m in the Dead Sea Depression to 8850 m (Mouth Everst). This range is generally too large for capturing in 255 values. Thus the color ramp for elevation data usually needs to be set dynamically.
AddRasterPalette
Following the ideas of DEM color ramps on stackexchange, the framework comes with four color ramps for elevation data. In the example below, the 4 palettes are set for dynamic ranges, indicated by the label auto set for all break and id points.
There are several web tools for setting and testing color ramps, including for instance Zonum Solutions Color Ramps Generator.
CreateLegend
The process Createlegend includes about 30 parameters for defining the legend and its layout. All parameters, except the columnhead (color ramp) can be left with the default setting for all continuous data. For elevation legends, you thus only need to give the columnhead.
ExportLegend
Legends with a fixed range can be exported as stand alone images. The example below exports the four elevation legends defined above calling the Framework process ExportLegend.
To create a canvas with all 4 legends, I used Image magick:
$ magick montage -background '#777777' -geometry +4+4 dem_dem_dem_darkest_fixed.png dem_dem_dem_dark_fixed.png dem_dem_dem_light_fixed.png dem_dem_dem_lightest_fixed.png dem_legends.png