GIS Tools

Language

Made withfor the GIS community

Label Placement Tool

Configure label collision detection and priority settings

Map Viewing

Drop files here or click to browse

Supported formats: GeoJSON

GeoJSON

or

Label Tips

  • Use Line placement for roads and rivers
  • Add a halo to improve readability over busy backgrounds
  • Adjust offset to prevent labels overlapping features
  • Labels automatically avoid overlapping each other

What Is Label Placement?

Label placement is the cartographic problem of putting text labels on a map so that they do not overlap each other, do not obscure important features, and remain associated with the feature they describe. It sounds simple but turns out to be mathematically difficult: automatic label placement is known to be NP-hard, meaning there is no known efficient algorithm that finds the optimal arrangement for large maps. Despite that, every modern GIS and web mapping library has to solve the problem well enough to produce legible output, and the tools they use β€” candidate positions, conflict graphs, greedy placement, simulated annealing, genetic algorithms β€” form one of the richest areas of applied cartography.

The gis.tools label placement tool gives you direct control over the label placement process: which features to label, what text to use, priority rules for which labels win in conflicts, halos and offsets for legibility, and minimum zoom thresholds so that low-priority labels disappear at small scales. It implements the same core techniques as QGIS's built-in label engine and ArcGIS Pro's Maplex Label Engine, scaled down for browser use.

The core challenge of label placement is that the number of possible label positions grows combinatorially with the number of features, and checking every combination is infeasible. All production label engines use heuristics to pick good-enough positions quickly.

How Label Placement Algorithms Work

Candidate positions

For each feature, the algorithm generates a set of candidate label positions. For points, the classic set is eight positions around the point: top, top-right, right, bottom-right, bottom, bottom-left, left, top-left, each ranked by cartographic preference (top-right is usually first). For lines, candidates are placed along the line at intervals. For polygons, candidates are inside the polygon at various points.

Conflict detection

Once candidates exist, the algorithm checks which candidates conflict with each other (would overlap if both were drawn). The result is a conflict graph where labels are nodes and overlaps are edges. The goal is to pick one candidate per feature such that no two selected candidates conflict.

Placement strategies

Greedy placement picks the highest-priority feature first, assigns its best candidate, removes conflicting candidates from other features, and repeats. Fast but can get stuck in suboptimal configurations.

Simulated annealing starts with a greedy solution and randomly swaps labels, accepting worse configurations with some probability that decreases over time. Often produces better results than pure greedy.

Genetic algorithms evolve a population of label layouts using mutation and crossover operators, selecting the fittest (fewest conflicts) for the next generation.

The gis.tools label placement tool uses a combination of greedy placement with simulated annealing refinement β€” the same general approach as QGIS's labeling engine.

Key Parameters and Options

Label field

The attribute whose value becomes the label text. Must be a string or numeric field.

Priority

A numeric priority that determines which labels win in conflicts. Use a feature attribute (e.g., city population) or a fixed priority per layer.

Font properties

Family, size, color, weight.

Halo

A light outline around the text that improves legibility against complex backgrounds. Typical: 1–2 pixel white halo on black text.

Offset

Push the label away from the feature by a fixed pixel distance. Prevents the label from overlapping its own feature.

Minimum zoom

Hide labels below a specific zoom level to prevent clutter at low zoom.

Collision margin

Extra padding around labels during collision checks. Larger margins produce sparser label layouts.

Allow overlap

For dense label sets where you would rather show all labels with some overlap than show only non-conflicting subsets.

Practical Applications

Street and place name labeling

The original use case: labeling roads with their names and cities with their names on a basemap. Different priorities ensure capital cities are labeled before villages, and major highways before residential streets.

Administrative boundary labeling

Countries, states, provinces, counties. Each needs a visible label inside its polygon, sized appropriately for the feature area.

Station and POI labeling

Transit maps, tourist guides, and wayfinding maps depend heavily on label placement. Priority rules ensure major stations label before minor ones.

Scientific and thematic maps

Climate zones, vegetation types, soil classes β€” any categorical polygon layer where the category name should appear in the polygon.

Infrastructure asset labeling

Utility companies label transformers, valves, and substations with asset IDs. Label placement ensures IDs do not stack on top of each other in dense areas.

Archaeological site maps

Site names, feature IDs, and excavation grid labels all need to coexist on a publication map without visual conflict.

Step-by-Step Workflow

  1. Load your data in the Online Map Viewer (Multi-Layer).
  2. Open the label placement panel.
  3. Select the label field.
  4. Choose a priority field if some features should label preferentially.
  5. Set font, size, color, halo.
  6. Adjust offset to prevent self-overlap.
  7. Set minimum zoom for low-priority labels.
  8. Run the placement engine and review results.
  9. For hand-tuning, enable per-feature overrides on critical labels.
  10. Export via Print Composer.

Worked Example: Labeling a City Dataset

You have a global cities GeoJSON with 30,000 points and a population field. Naively labeling every city at all zoom levels would produce an illegible mess of overlapping names at low zoom. Using priority equal to population, you ask the engine to place labels such that higher-population cities always win conflicts. You also set a minimum zoom per population band: cities over 1 million are labeled from zoom 3; cities 100k–1M from zoom 6; smaller towns only from zoom 10. The resulting labeled map shows a clean global pattern of megacities at low zoom that progressively enriches with smaller places as the user zooms in.

Common Pitfalls and Gotchas

  • No halo. Labels without halos become unreadable against complex basemaps.
  • Uniform priority. Without priority differentiation, the placement engine cannot break conflicts meaningfully.
  • Over-labeling. Trying to label every feature at every zoom level produces clutter. Use minimum zoom.
  • Fixed label positions. Forcing all labels to the same side of their features produces visible conflict strips.
  • Ignoring label length. Long place names (Llanfairpwllgwyngyll) break layouts designed for short names.
  • Multi-part features. A MultiPolygon with many small parts should label only the largest part, not all of them.
  • CRS-dependent placement. Label offsets in pixels work independently of zoom; real-world offsets in meters depend on latitude.

Tips for Best Results

  • Always use a 1–2 pixel halo in a contrasting color.
  • Prioritize features by importance (population, area, rank).
  • Use minimum zoom thresholds to stage label density by scale.
  • Keep font sizes consistent within a map but vary by priority.
  • For linear features, orient labels along the line.
  • For polygon features, label inside the largest inscribed circle.
  • Leave breathing room β€” set a reasonable collision margin.

Comparison with Desktop GIS

ArcGIS Pro's Maplex Label Engine is the gold standard for automatic label placement with dozens of knobs: curved text along roads, stack long names, label ordering by feature weight. QGIS's built-in labeling is similarly sophisticated with rule-based placement and data-defined expressions. The gis.tools tool is lighter-weight but covers the core capabilities needed for interactive web cartography.

Performance Considerations

Label placement is the most expensive rendering step after basic geometry. For large datasets, the collision detection pass dominates. Supercluster-style spatial indexing keeps the cost manageable, but expect slower frame rates when many thousands of labels are visible simultaneously.

Data Privacy and Browser-Based Processing

Label text comes from your attribute data. That data stays in your browser β€” the label placement engine never transmits it.

Related GIS Concepts

Conflict graph. A graph representation of label overlaps used by placement algorithms.

Cartographic hierarchy. The practice of using size, color, and priority to communicate feature importance.

Typographic hierarchy. Font weight, size, and style conventions that complement label placement.

Label-free rendering. A technique where labels are separated into their own layer that can be toggled independently.

Frequently Asked Questions

Why do some of my labels not appear?

Either the collision detection eliminated them due to conflicts with higher-priority labels, or they fell below the minimum zoom threshold.

Can I manually place a specific label?

Yes β€” per-feature overrides let you pin a label to a specific position.

How do I label lines along their direction?

Enable the line-follow placement option, which curves text along the feature.

Why do labels flicker when I pan?

The collision detection is re-running with the new viewport. At high feature counts this can cause visible reflow.

Related Tools on gis.tools

100% client-side processing - your data stays private and never leaves your device