Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Styling Natural Earth with GeoServer and GeoCSS...

Styling Natural Earth with GeoServer and GeoCSS - FOSS4G 2023

Natural Earth is a public domain map dataset available at 1:10m, 1:50m, and 1:110 million scales. Featuring tightly integrated vector and raster data, with Natural Earth one can build a variety of visually pleasing, well-crafted maps with cartography or GIS software.

GeoServer GeoCSS is a CSS inspired language allowing you to build maps without consuming fingertips in the process, while providing all the same abilities as SLD.

In this talk, the presenters will show how they have built a world political map and a world geographic map based on Natural Earth, using CSS, and shared the results on GitHub. They will share with you how simple, compact styles can be used to prepare a multiscale map, including:
* Leveraging CSS cascading.
* Building styles that respond to scales in ways that go beyond simple scale dependencies.
* Various types of labeling tricks (conflict resolution and label priority, controlling label density, label placement, typography, labels in various scripts, label shields and more).
* Quickly controlling colors with LessCSS inspired functions.
* Building symbology using GeoServer large set of well known marks.

Simone Giannecchini

October 17, 2023
Tweet

More Decks by Simone Giannecchini

Other Decks in Technology

Transcript

  1. 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
  2. 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
  3. Natural Earth • Natural Earth is a public domain map

    dataset • Featuring tightly integrated vector and raster data
  4. 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; }
  5. 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?
  6. 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
  7. 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; } }
  8. 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
  9. 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')];
  10. 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;
  11. 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; }
  12. 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'; }
  13. 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; }; }
  14. 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';
  15. 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; }; }; }
  16. 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; };
  17. 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