Slide 1

Slide 1 text

Andrea Aime GeoSolutions Styling Natural Earth with GeoServer CSS

Slide 2

Slide 2 text

GeoSolutions Enterprise Support Services Deployment Subscription Professional Training Customized Solutions GeoNode • Offices in Italy & US, Global Clients/Team • 30+ collaborators, 25+ Engineers • Our products • Our Offer

Slide 3

Slide 3 text

Affiliations We strongly support Open Source, it Is in our core We actively participate in OGC working groups and get funded to advance new open standards We support standards critical to GEOINT

Slide 4

Slide 4 text

Intro: Natural Earth and GeoCSS

Slide 5

Slide 5 text

Natural Earth • Natural Earth is a public domain map dataset • Featuring tightly integrated vector and raster data

Slide 6

Slide 6 text

Natural Earth, datasets • Data available at 1:10m, 1:50m, and 1:110 million scales.

Slide 7

Slide 7 text

Natural Earth, some 10m data

Slide 8

Slide 8 text

GeoServer CSS (GeoCSS) • CSS inspired language for map styling • Compact, powerful, human readable, human writable * { stroke: blue; fill: #7EB5D3; label: [name]; label-anchor: 0.5 0.5; font-fill: black; font-family: "Arial"; font-size: 14; halo-radius: 2; halo-color: #7EB5D3; halo-opacity:0.8; }

Slide 9

Slide 9 text

A basemap for training purposes • Wanted to have a significant, yet not too complicated, base map, in CSS, for GeoSolutions’ training package • What about osm-styles?

Slide 10

Slide 10 text

osm-styles is too big • Nice, comprehensive, used in geoserver.org too • But way too big roads.css

Slide 11

Slide 11 text

Setting up for a simpler map • Let’s do Natural Earth instead • With simple, yet interesting, styles • Inspiration: the printed maps found in atlases when I was a kid

Slide 12

Slide 12 text

The political map

Slide 13

Slide 13 text

Political map of the world

Slide 14

Slide 14 text

Political map of the world

Slide 15

Slide 15 text

Political map of the world

Slide 16

Slide 16 text

Political map of the world

Slide 17

Slide 17 text

The layer group

Slide 18

Slide 18 text

Simple yet interesting: oceans /* @title ocean */ [@sd > 70M] { fill: lighten(lightblue, 15%), symbol('shape://slash'); :fill { size: 5; stroke: lighten(lightblue, 10%); stroke-width: 1; } }

Slide 19

Slide 19 text

Using external tools: color brewer • Color countries so that no two neighbouring share the same color • MAPCOLOR7 attribute supports use case • colorbrewer2.org to pick colors

Slide 20

Slide 20 text

Turning brewer into CSS fill: [Recode(MAPCOLOR7, 1, '#fbb4ae', 2, lighten('#b3cde3', '5%'), 3, '#ccebc5', 4, lighten('#decbe4', '5%'), 5, '#fed9a6', 6, '#ffffcc', 7, '#e5d8bd')];

Slide 21

Slide 21 text

Labelling countries label: [NAME]; label-anchor: 0.5 0.5; font-family: 'Noto Sans'; font-size: 14; font-fill: lighten(black, 20%); halo-color: white; halo-radius: 1; label-priority: [POP_EST]; label-auto-wrap: 100; label-max-displacement: 50;

Slide 22

Slide 22 text

Pen up, pen down, pen up, … /* @title States */ [@sd > 20M] [@sd < 70M] { stroke: darkgray; stroke-dasharray: 4 4; stroke-width: 0.1; label: [name]; label-anchor: 0.5 0.5; font-family: 'Noto Sans'; font-size: 10; font-fill: black; halo-color: white; halo-radius: 1; halo-opacity: 50%; label-auto-wrap: 70; label-max-displacement: 50; label-fit-goodness: 0.8; label-priority: 50M; }

Slide 23

Slide 23 text

Getting the right blend… /* @title Urban areas */ [@sd < 70M][@sd > 20M] { fill: lightgray; } /* @title Urban areas */ [@sd < 70M][@sd > 20M] { fill: lightgray; fill-opacity: 70%; composite: 'multiply'; }

Slide 24

Slide 24 text

Continuously adapt size /* @title States and provinces */ [@sd < 20M] { stroke: darkgray; stroke-dasharray: 4 4; stroke-width: [interpolate(@sd, 2M, 2, 10M, 0.1)]; label: [name]; label-anchor: 0.5 0.5; … [scalerank <= 2] { font-size: [interpolate(@sd, 2M, 16, 20M, 10)]; label-priority: 50M; }; }

Slide 25

Slide 25 text

Roads… it’s never easy /* @title Roads */ [@sd < 20M] { [featurecla = 'Ferry'] { stroke: lighten(blue, 30%); stroke-dasharray: 4 4; }; [featurecla = 'Road'] { [@sd < 10M] { stroke: desaturate(darkorange, 50%); stroke-width: 0.5; }; [@sd < 10M][type = 'Secondary Highway'] { stroke: darkorange; stroke-width: 1; }; [@sd < 20M][type = 'Major Highway'] { stroke: orange, yellow; stroke-width: 3, 1; z-index: 0, 1; label: [local]; label-anchor: 0.5 0.5; font-family: 'Noto Sans';

Slide 26

Slide 26 text

Roads… it’s never easy /* @title Roads */ [@sd < 20M] { [featurecla = 'Ferry'] { stroke: lighten(blue, 30%); stroke-dasharray: 4 4; }; [featurecla = 'Road'] { [@sd < 10M] { stroke: desaturate(darkorange, 50%); stroke-width: 0.5; }; [@sd < 10M][type = 'Secondary Highway'] { stroke: darkorange; stroke-width: 1; }; [@sd < 20M][type = 'Major Highway'] { stroke: orange, yellow; stroke-width: 3, 1; z-index: 0, 1; }; }; }

Slide 27

Slide 27 text

And road plates too label: [local]; label-anchor: 0.5 0.5; font-family: 'Noto Sans'; font-fill: black; label-group: true; label-repeat: 200; shield: symbol(square); shield-resize: stretch; shield-margin: 2; :shield { fill: white; stroke: orange; stroke-width: 0.2; };

Slide 28

Slide 28 text

How about a physical map?

Slide 29

Slide 29 text

Physical map of the world

Slide 30

Slide 30 text

Physical map of the world

Slide 31

Slide 31 text

Ok, how can I get it?

Slide 32

Slide 32 text

But on GitHub, of course! • GeoSolution’s Natural Earth styles repository • https://github.com/geosolutions-it/ne-styles • The physical map is in a branch right now: • https://github.com/geosolutions-it/ne-styles/tree /physical

Slide 33

Slide 33 text

That’s all folks! Questions? [email protected] [email protected]