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

Styling Natural Earth with GeoServer and GeoCSS - FOSS4G 2023

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. Andrea Aime
    GeoSolutions
    Styling Natural Earth
    with GeoServer CSS

    View full-size slide

  2. 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

    View full-size slide

  3. 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

    View full-size slide

  4. Intro: Natural Earth and GeoCSS

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  7. Natural Earth, some 10m data

    View full-size slide

  8. 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;
    }

    View full-size slide

  9. 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?

    View full-size slide

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

    View full-size slide

  11. 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

    View full-size slide

  12. The political map

    View full-size slide

  13. Political map of the world

    View full-size slide

  14. Political map of the world

    View full-size slide

  15. Political map of the world

    View full-size slide

  16. Political map of the world

    View full-size slide

  17. The layer group

    View full-size slide

  18. 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;
    }
    }

    View full-size slide

  19. 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

    View full-size slide

  20. 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')];

    View full-size slide

  21. 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;

    View full-size slide

  22. 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;
    }

    View full-size slide

  23. 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';
    }

    View full-size slide

  24. 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;
    };
    }

    View full-size slide

  25. 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';

    View full-size slide

  26. 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;
    };
    };
    }

    View full-size slide

  27. 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;
    };

    View full-size slide

  28. How about a physical map?

    View full-size slide

  29. Physical map of the world

    View full-size slide

  30. Physical map of the world

    View full-size slide

  31. Ok, how can I get it?

    View full-size slide

  32. 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

    View full-size slide