9.5 Centroids, Convex Hulls, and Shape Metrics
Representative points, bounding geometries, and quantitative shape descriptors.
Key takeaways
- Centroids represent a feature with a single point; pole-of-inaccessibility is often a better label location.
- Convex hulls, concave hulls, and oriented bounding boxes summarise the extent of a set of geometries.
- Shape metrics (compactness, elongation) quantify geometric character for statistical or ML use.
Introduction
Beyond predicates and overlays, GIS frequently needs to summarise geometry: the centre, the extent, or numerical properties like compactness. These derived shapes and metrics are the glue of many analyses. This lesson covers the most useful ones.
Centroid
The centroid is the geometric centre of mass of a feature. For a uniform-density polygon:
SELECT ST_Centroid(geom) FROM parks;Uses:
- Labelling (place the label at the centroid).
- Distance calculations when full polygons are overkill.
- Aggregating a polygon to a "point proxy" for statistical analysis.
Caveat: the centroid of a donut- or crescent-shaped polygon may fall outside the polygon. For labels, consider the pole of inaccessibility.
Pole of inaccessibility (PIA)
The point furthest from any boundary edge. Always inside the polygon, unlike the centroid. Computed via iterative quadtree refinement (Mapbox's polylabel algorithm).
1from shapely.ops import unary_union
2from mapbox.polylabel import polylabelUse PIA for:
- Label placement inside complex polygons.
- "Representative point" when you need a guaranteed interior point.
PostGIS 3.3+: ST_MaximumInscribedCircle returns a related concept.
Convex hull
The smallest convex polygon containing the input geometry or geometry set. Like a rubber band stretched around the features.
SELECT ST_ConvexHull(ST_Collect(geom)) FROM events;Uses:
- Drawing an "extent" polygon.
- Density-of-coverage analysis.
- Simplifying complex footprints for a rough outline.
Concave hull
A concave hull (also called alpha shape) follows the outer boundary of a point cloud more tightly than a convex hull. PostGIS 3.2+: ST_ConcaveHull(geom, target_percent).
Uses:
- Footprint of clustered points (a city's actual shape vs its rubber-band convex hull).
- Alpha shapes for archaeological site boundaries.
- Drone-surveyed area outlines.
Parameters trade off detail vs smoothness; experiment.
Minimum bounding geometries
- Axis-aligned bounding box —
ST_Envelope(geom)— the smallest rectangle with sides parallel to the axes. - Oriented bounding box (OBB) — rotated rectangle minimising area.
- Minimum bounding circle — smallest circle enclosing a geometry.
1ST_Envelope(geom)
2ST_OrientedEnvelope(geom) -- PostGIS 3.3+
3ST_MinimumBoundingCircle(geom)Shape metrics
Quantitative descriptors of geometric form:
Compactness (Polsby-Popper)
Ratio of polygon area to the area of a circle with the same perimeter:
$$\text{PP} = \frac{4\pi \cdot \text{area}}{\text{perimeter}^2}$$
PP ranges 0 (very elongated) to 1 (perfect circle). Common metric for gerrymandering analysis.
1SELECT id,
2 4 * pi() * ST_Area(geom) / POWER(ST_Perimeter(geom), 2) AS polsby_popper
3FROM districts;Elongation / aspect ratio
Ratio of the oriented bounding box's long side to its short side. High values = stretched features (rivers, highways, boundary fragments).
Fractal dimension
Approximates the roughness of a boundary. Natural features (coastlines, forest edges) tend toward higher fractal dimensions than human-built features.
Shape index
$$S = \frac{\text{perimeter}}{2 \sqrt{\pi \cdot \text{area}}}$$
Closely related to Polsby-Popper; geographers have half a dozen variants.
Use cases for shape metrics
- Urban form — classify city districts by compactness.
- Habitat ecology — fragmented forests have more edge relative to area.
- Political districting — gerrymandered districts have low Polsby-Popper.
- Land parcels — elongated parcels often indicate road frontage.
Computing summary stats in GeoPandas
1import geopandas as gpd
2import numpy as np
3[object Object]
4Self-check exercises
1. When is the centroid a bad label point, and what's the alternative?
For concave, crescent, or doughnut-shaped polygons the centroid can fall outside the polygon. The pole of inaccessibility (Mapbox's polylabel algorithm, PostGIS ST_MaximumInscribedCircle) always falls inside and is typically a better label location.
2. What does a low Polsby-Popper score tell you about a district?
It's elongated or irregular, with a long perimeter relative to its area. In districting analysis this often signals gerrymandering; in ecology it signals a fragmented habitat; in urban form it could indicate a linear development (along a river or road).
3. Convex hull vs concave hull — when would you pick each?
Convex hull for a quick "extent" outline or when you need a convex polygon (some algorithms require it). Concave hull when you need the shape to follow the data more tightly — e.g., the true outline of a city from its point cloud of buildings, or the alpha-shape of archaeological finds. Concave hulls are adjustable via a concavity parameter.
Summary
- Centroid and pole of inaccessibility are both "representative points" with different guarantees.
- Convex, concave hulls and bounding boxes summarise extent.
- Shape metrics (Polsby-Popper, elongation, fractal dimension) quantify geometric character.
- These derived properties feed downstream cartography, statistics, and machine learning.
Further reading
- Polsby & Popper (1991) — The third criterion: compactness as a procedural safeguard.
- MacEachren, A. — Compactness of geographic shape.
- Mapbox blog — A new algorithm for finding a visual center of a polygon.
- "Alpha shapes" foundational paper (Edelsbrunner, 1983).