Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
โ† Certified GeoServer/KoboToolbox User Level Three ยท Lesson 3 of 12

Module Two

๐Ÿ“– Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
3
Module 2: Advanced Styling with SLD & CSS
Level Three ยท Module 2

Advanced Styling with SLD & CSS

Master cartographic styling in GeoServer using Styled Layer Descriptor (SLD) and CSS, including rule-based rendering, scale dependencies, conditional filters, and rendering transformations.

Duration: 6 hours Format: Theory + Hands-on Lab Prerequisites: Module 1

Module Overview

Cartographic styling transforms raw spatial data into meaningful, readable maps. This module explores GeoServer's two primary styling mechanisms: Styled Layer Descriptor (SLD), an OGC-standard XML styling language, and the more concise CSS styling extension. Learners will progress from basic symbolizers to advanced rule-based rendering with scale dependencies, filters, and label placement.

The module also introduces rendering transformations, which apply processing (such as heatmaps or aggregations) during map generation, enabling dynamic, data-driven visualizations.

Learning Objectives

  • Explain the structure of an SLD document, including rules, filters, and symbolizers.
  • Author rule-based styles with conditional filters and scale dependencies.
  • Use the CSS styling extension to write concise, maintainable styles.
  • Implement thematic styling to visualize attributes such as categories or ranges.
  • Configure rendering transformations such as heatmaps and aggregations.
  • Apply label placement strategies and resolve label conflicts.

Topics Covered

2.1 SLD Fundamentals

  • SLD document structure
  • Named layers and styles
  • FeatureTypeStyle and rules
  • Symbolizers: point, line, polygon, text

2.2 Rules & Filters

  • Rule ordering and evaluation
  • Attribute and comparison filters
  • Else filters and scale dependencies
  • Combining multiple conditions

2.3 CSS Styling Extension

  • CSS syntax for GeoServer
  • Simplified rule definitions
  • Nested and conditional styles
  • When to prefer CSS over SLD

2.4 Thematic Styling

  • Categorized (qualitative) styling
  • Graduated (quantitative) styling
  • Color ramp design
  • Legend generation considerations

2.5 Rendering Transformations

  • What rendering transformations do
  • Heatmap rendering
  • Aggregation and clustering
  • Performance considerations

2.6 Label Placement

  • Point, line, and polygon labeling
  • Conflict resolution strategies
  • Halo and displacement options
  • Scale-dependent labeling

Detailed Content

2.1 SLD Fundamentals

An SLD document is an XML file that describes how features should be rendered. It is composed of one or more <FeatureTypeStyle> elements, each containing <Rule> elements. Each rule may contain one or more symbolizers that determine the visual appearance of features.

  • Point symbolizer: Draws markers for point features.
  • Line symbolizer: Draws strokes for linear features.
  • Polygon symbolizer: Fills and strokes polygon features.
  • Text symbolizer: Places labels on features.
<StyledLayerDescriptor version="1.0.0">
  <NamedLayer>
    <Name>workspace:roads</Name>
    <UserStyle>
      <FeatureTypeStyle>
        <Rule>
          <LineSymbolizer>
            <Stroke>
              <CssParameter name="stroke">#333333</CssParameter>
              <CssParameter name="stroke-width">2</CssParameter>
            </Stroke>
          </LineSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

2.2 Rules & Filters

Rules control which features a style applies to. Filters restrict a rule to features matching specific conditions, while scale dependencies control visibility at different zoom levels.

  • Attribute filters: Match features where an attribute equals a value.
  • Comparison filters: Use operators such as >, <, >=, and <=.
  • Scale dependencies: Use <MinScaleDenominator> and <MaxScaleDenominator> to control zoom visibility.
  • Else filters: Apply when no other rule matches.
Filter TypePurposeExample
PropertyIsEqualToExact matchtype = 'highway'
PropertyIsGreaterThanNumeric comparisonpopulation > 10000
PropertyIsBetweenRange matchvalue between 10 and 50
And / OrCombine conditionstype = 'road' AND lanes > 2

2.3 CSS Styling Extension

The CSS extension offers a compact alternative to SLD, using a syntax similar to web CSS. It is often easier to read and maintain for complex styles, though not all SLD features are supported.

/* Example CSS style */
* {
  stroke: #333333;
  stroke-width: 2;
}

[type = 'highway'] {
  stroke: #ff6600;
  stroke-width: 4;
}

[type = 'residential'][@scale < 50000] {
  stroke: #999999;
}
Best practice Use CSS for readability and rapid iteration, but fall back to SLD when you need advanced features such as multiple symbolizers or complex rendering transformations.

2.4 Thematic Styling

Thematic styling visualizes data attributes through color and symbols. Two common approaches are:

  • Categorized styling: Assign distinct colors to qualitative categories (e.g., land use types).
  • Graduated styling: Assign a color ramp to quantitative ranges (e.g., population density).
Style TypeData TypeExample
CategorizedQualitativeLand use: residential, commercial, industrial
GraduatedQuantitativePopulation density ranges
Warning Poor color choices can mislead interpretation. Ensure adequate contrast and accessibility, and avoid using red-green combinations that are difficult for color-blind users.

2.5 Rendering Transformations

Rendering transformations apply processing during map generation, enabling dynamic visualizations that go beyond static styling.

  • Heatmap: Visualizes point density as a color gradient.
  • Aggregation: Groups features into clusters for readability at low zoom levels.
  • Performance: Some transformations are computationally intensive; cache results where possible.
<!-- Example heatmap rendering transformation -->
<FeatureTypeStyle>
  <Transformation>
    <ogc:Function name="vec:Heatmap">
      <ogc:Literal>the_geom</ogc:Literal>
      <ogc:Literal>weight</ogc:Literal>
    </ogc:Function>
  </Transformation>
</FeatureTypeStyle>

2.6 Label Placement

Labels improve map readability but can clutter dense datasets. GeoServer provides several strategies to manage label placement and conflicts.

  • Point labeling: Place labels near point features with displacement options.
  • Line labeling: Align labels along lines for linear features.
  • Polygon labeling: Place labels at centroids for polygon features.
  • Conflict resolution: Use <VendorOption name="conflictResolution">true</VendorOption> to hide overlapping labels.
  • Halo: Add a contrasting outline to improve legibility.

Hands-On Lab: Author Rule-Based and Scale-Dependent SLD Styles

In this lab, you will create a sophisticated style for a road network layer, incorporating rule-based filters, scale dependencies, thematic coloring, and label placement.

Lab Steps

  1. Publish a road network layer (e.g., from OSM data or a shapefile) into a workspace.
  2. Author an SLD style with separate rules for highway, residential, and service roads, each with distinct stroke widths and colors.
  3. Add scale dependencies so that minor roads are hidden at zoom levels below 1:50000.
  4. Write an equivalent CSS style and compare readability and maintainability.
  5. Add a graduated style to a numeric attribute (e.g., lanes) using a color ramp.
  6. Enable conflictResolution and add a halo to a text symbolizer for road name labels.
  7. Preview the style in GeoServer's layer preview and refine as needed.
Deliverable: A working SLD style and an equivalent CSS style applied to the road layer, demonstrating rule-based rendering, scale dependencies, thematic styling, and label placement. Include a short comparison of SLD vs. CSS maintainability.

Suggested Session Timeline (6 Hours)

  • 0:00 โ€“ 0:45 โ€” SLD fundamentals and structure
  • 0:45 โ€“ 1:30 โ€” Rules, filters, and scale dependencies
  • 1:30 โ€“ 2:15 โ€” CSS styling extension
  • 2:15 โ€“ 2:30 โ€” Break
  • 2:30 โ€“ 3:15 โ€” Thematic styling (categorized and graduated)
  • 3:15 โ€“ 4:00 โ€” Rendering transformations and label placement
  • 4:00 โ€“ 5:30 โ€” Hands-on lab
  • 5:30 โ€“ 6:00 โ€” Review, Q&A, and lab debrief

Assessment

CriteriaWeight
SLD style correctness (rules, filters, scale)30%
CSS style equivalence and readability20%
Thematic styling quality20%
Label placement and conflict resolution15%
SLD vs. CSS comparison write-up15%

Pass mark for this module: 70%

Resources

  • GeoServer User Manual โ€” Styling (SLD and CSS)
  • OGC Styled Layer Descriptor (SLD) specification
  • GeoServer CSS extension documentation
  • Cartographic design guides (color ramps, typography, accessibility)
  • Sample vector datasets (roads, land use, administrative boundaries)
© 2026 Certified GeoServer/KoboToolbox User โ€” Level Three ยท Module 2: Advanced Styling with SLD & CSS

๐Ÿ† Get Certified

๐Ÿ”’

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (โ‚ฆ2,000 or 20,000 coins), and get a verified certificate with your name on it.

๐ŸŽ“ Sign Up to Get Certified
๐Ÿ› ๏ธ Practice Tools
Hands-on simulators & labs - subscription required.
โ†’
๐ŸŽฏ Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
โ†’