Mapping in GeoServer with SLD and CSS

48
Advanced cartographic map rendering in GeoServer Ing. Andrea Aime, GeoSolutions FOSS4G 2014, Portland 8 th -13 th September 2014

description

Various software can style maps and generate a proper SLD document for OGC compliant WMS like GeoServer to use. However, in most occasions, the styling allowed by the graphical tools is pretty limited and not good enough to achieve good looking, readable and efficient cartographic output. For those that like to write their own styles CSS also represents a nice alternatives thanks to its compact-ness and expressiveness. Several topics will be covered, providing examples in both SLD and CSS for each, including: mastering multi-scale styling, using GeoServer extensions to build common hatch patterns, line styling beyond the basics, such as cased lines, controlling symbols along a line and the way they repeat, leveraging TTF symbol fonts and SVGs to generate good looking point thematic maps, using the full power of GeoServer label lay-outing tools to build pleasant, informative maps on both point, polygon and line layers, including adding road plates around labels, leverage the labelling subsystem conflict resolution engine to avoid overlaps in stand alone point symbology, blending charts into a map, dynamically transform data during rendering to get more explicative maps without the need to pre-process a large amount of views. The presentation aims to provide the attendees with enough information to master SLD/CSS documents and most of GeoServer extensions to generate fast, appealing, informative and readable maps.

Transcript of Mapping in GeoServer with SLD and CSS

Page 1: Mapping in GeoServer with SLD and CSS

Advanced cartographic map rendering in GeoServer

Ing. Andrea Aime, GeoSolutions

FOSS4G 2014, Portland 8th-13th September 2014

Page 2: Mapping in GeoServer with SLD and CSS

Overview

Who we are

Example map

Raster styling

Scale dependent rules

Hatches, patterns and dashes

Point Symbology

Labeling

Transformations

Cross layer filtering

FOSS4G 2014, Portland 8th-13th September 2014

2

Page 3: Mapping in GeoServer with SLD and CSS

GeoSolutions

Founded in Italy in late 2006

Expertise

• Image Processing, GeoSpatial Data Fusion

• Java, Java Enterprise, C++, Python

• JPEG2000, JPIP, Advanced 2D visualization

Supporting/Developing FOSS4G projects

GeoTools, GeoServer

GeoBatch, GeoNetwork

Clients

Public Agencies

Private Companies

http://www.geo-solutions.it

FOSS4G 2014, Portland 8th-13th September 2014

3

Page 4: Mapping in GeoServer with SLD and CSS

Introduction

FOSS4G 2014, Portland 8th-13th September 2014

Page 5: Mapping in GeoServer with SLD and CSS

SLD vs CSS

Styled Layer Descriptor

OGC standard

XML based, verbose, hard to hand edit

Only showing relevant bits of the SLD

GeoCSS

CSS with extensions for map rendering

Simple, Compact, designed for human beings

Not a standard (several incompatible variants for mapping)

Showing the full style, it’s that short

FOSS4G 2014, Portland 8th-13th September 2014

5

Page 6: Mapping in GeoServer with SLD and CSS

Example map

FOSS4G 2014, Portland 8th-13th September 2014

6

Page 7: Mapping in GeoServer with SLD and CSS

Example map

FOSS4G 2014, Portland 8th-13th September 2014

7

Page 8: Mapping in GeoServer with SLD and CSS

Example map

FOSS4G 2014, Portland 8th-13th September 2014

8

Page 9: Mapping in GeoServer with SLD and CSS

Example map

FOSS4G 2014, Portland 8th-13th September 2014

9

Page 10: Mapping in GeoServer with SLD and CSS

Example map

FOSS4G 2014, Portland 8th-13th September 2014

10

Page 11: Mapping in GeoServer with SLD and CSS

Raster styling

FOSS4G 2014, Portland 8th-13th September 2014

Page 12: Mapping in GeoServer with SLD and CSS

A DEM and a color map

SRTM from USGS

Standard color map

Just avoid the nodata values with opacity=0

FOSS4G 2014, Portland 8th-13th September 2014

12

Page 13: Mapping in GeoServer with SLD and CSS

A DEM and a color map

Same as before, in CSS

Solid intervals

FOSS4G 2014, Portland 8th-13th September 2014

13

Page 14: Mapping in GeoServer with SLD and CSS

Hatches, patterns, dashes and plates

FOSS4G 2014, Portland 8th-13th September 2014

Page 15: Mapping in GeoServer with SLD and CSS

Filling with patterns

FOSS4G 2014, Portland 8th-13th September 2014

15

Page 16: Mapping in GeoServer with SLD and CSS

Filling with TTF fonts

FOSS4G 2014, Portland 8th-13th September 2014

16

Page 17: Mapping in GeoServer with SLD and CSS

Hatches

FOSS4G 2014, Portland 8th-13th September 2014

17

Page 18: Mapping in GeoServer with SLD and CSS

Hatches

FOSS4G 2014, Portland 8th-13th September 2014

shape://vertiline shape://horline

shape://slash shape://backslash

shape://plus shape://times

18

Page 19: Mapping in GeoServer with SLD and CSS

Dashes

FOSS4G 2014, Portland 8th-13th September 2014

19

Page 20: Mapping in GeoServer with SLD and CSS

Dashes

FOSS4G 2014, Portland 8th-13th September 2014

20

Page 21: Mapping in GeoServer with SLD and CSS

Plates

FOSS4G 2014, Portland 8th-13th September 2014

Page 22: Mapping in GeoServer with SLD and CSS

Plates CSS way

FOSS4G 2014, Portland 8th-13th September 2014

22

Page 23: Mapping in GeoServer with SLD and CSS

Point Symbology

23 FOSS4G 2014, Portland 8th-13th September 2014

Page 24: Mapping in GeoServer with SLD and CSS

Point symbols

• 600 loc for 6 different points types

• Painful…

FOSS4G 2014, Portland 8th-13th September 2014

24

Page 25: Mapping in GeoServer with SLD and CSS

Point symbols

• 70 lines total • Power of cascading

25

FOSS4G 2014, Portland 8th-13th September 2014

Page 26: Mapping in GeoServer with SLD and CSS

Dynamic symbolizers

FOSS4G 2014, Portland 8th-13th September 2014

26

Page 27: Mapping in GeoServer with SLD and CSS

Dynamic symbolizers CSS way

• Down to 15 lines

FOSS4G 2014, Portland 8th-13th September 2014

27

Page 28: Mapping in GeoServer with SLD and CSS

Labeling

FOSS4G 2014, Portland 8th-13th September 2014

Page 29: Mapping in GeoServer with SLD and CSS

Line labels

FOSS4G 2014, Portland 8th-13th September 2014

29

Page 30: Mapping in GeoServer with SLD and CSS

Line labels (and more) CSS way

FOSS4G 2014, Portland 8th-13th September 2014

30

Page 31: Mapping in GeoServer with SLD and CSS

Point labels

FOSS4G 2014, Portland 8th-13th September 2014

31

Page 32: Mapping in GeoServer with SLD and CSS

Polygon labels

32

FOSS4G 2014, Portland 8th-13th September 2014

Page 33: Mapping in GeoServer with SLD and CSS

Label Obstacles

FOSS4G 2014, Portland 8th-13th September 2014

33

Page 34: Mapping in GeoServer with SLD and CSS

Scale dependent rules

FOSS4G 2014, Portland 8th-13th September 2014

Page 35: Mapping in GeoServer with SLD and CSS

Scale dependent rules

Too often forgotten or little used, yet very important:

Hide layers when too zoomed in (raster/vector example)

Progressively show details

Add more expensive rendering when there are less features

Key to any high performance / good looking map

FOSS4G 2014, Portland 8th-13th September 2014

35

Page 36: Mapping in GeoServer with SLD and CSS

Example

FOSS4G 2014, Portland 8th-13th September 2014

36

Page 37: Mapping in GeoServer with SLD and CSS

Hide as you zoom in

Add a MinScaleDenominator to the rule

This will make the layer disappear at 1:75000 (towards 1:1)

FOSS4G 2014, Portland 8th-13th September 2014

37

Page 38: Mapping in GeoServer with SLD and CSS

Alternative rendering

Simple rendering at low scale (up to 1:2000)

More complex rendering when zoomed in (1:1999 and above)

FOSS4G 2014, Portland 8th-13th September 2014

38

Page 39: Mapping in GeoServer with SLD and CSS

Alternative rendering

FOSS4G 2014, Portland 8th-13th September 2014

39

Page 40: Mapping in GeoServer with SLD and CSS

Alternative rendering, CSS way

FOSS4G 2014, Portland 8th-13th September 2014

40

Page 41: Mapping in GeoServer with SLD and CSS

Transformations

FOSS4G 2014, Portland 8th-13th September 2014

Page 42: Mapping in GeoServer with SLD and CSS

Geometry transformations

FOSS4G 2014, Portland 8th-13th September 2014

42

Page 43: Mapping in GeoServer with SLD and CSS

Geometry transformations CSS way

FOSS4G 2014, Portland 8th-13th September 2014

43

Page 44: Mapping in GeoServer with SLD and CSS

Rendering tx: isolines

• No CSS support yet

FOSS4G 2014, Portland 8th-13th September 2014

44

Page 45: Mapping in GeoServer with SLD and CSS

Rendering tx: point extraction

FOSS4G 2014, Portland 8th-13th September 2014

45

Page 46: Mapping in GeoServer with SLD and CSS

Rendering tx: dynamic color map

FOSS4G 2014, Portland 8th-13th September 2014

QGIS palettes

GDAL pam stats

Input raster

Dynamic ColorMap

Map!

46

Page 47: Mapping in GeoServer with SLD and CSS

Wind barbs

FOSS4G 2014, Portland 8th-13th September 2014

windbarbs://$(value)[m/s]?emisphere=(n/s)

windbarbs://15 [m/s]?emisphere=n

47

Page 48: Mapping in GeoServer with SLD and CSS

The End

Questions? [email protected]

[email protected]

FOSS4G 2014, Portland 8th-13th September 2014

48