The problem
Contour lines are still one of the most-produced vector layers in GIS: topographic
map series, LiDAR deliverables, nautical depth contours, engineering site models.
Almost all of it runs through GDAL’s contour generator: directly as
gdal_contour, or indirectly through QGIS, PostGIS ST_Contour, MapServer and
most tile pipelines. GDAL is good. It is also single-threaded, so a fine contour
interval on a large DEM turns into a batch job.
Pipelines work around this by
tiling the DEM and running many gdal_contour processes in parallel.
Head-to-head on real elevation data
Same raster, same levels, every tool in-process (no start-up or file I/O in the timed region). GDAL is measured both as released (3.13.3) and as the current development code that becomes 3.14.
| Dataset | Grid · levels | isosweep1 thread | isosweep48 threads | GDAL 3.14-dev1 thread | GDAL 3.13.31 thread | VTK Flying Edges1 thread | ContourPy1 thread | VTK Flying Edges32 threads | ContourPy48 threads | Speed-upvs fastest 1-thread | Speed-upvs fastest overall |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Copernicus 30 m DEM, Alps 1° tile real data | 3,600 × 3,600 · every 20 m | 727 ms | 53.2 ms | 3.79 s | 3.75 s | 12.7 s | 11.1 s | 6.08 s | 750 ms | 5.2× | 14× |
| Copernicus 30 m DEM, Alps 2°×2° mosaic real data | 7,200 × 7,200 · every 50 m | 1.42 s | 95.6 ms | 7.11 s | 7.10 s | 26.8 s | 20.2 s | 14.8 s | 884 ms | 5.0× | 9.2× |
| Mid-Atlantic Ridge multibeam bathymetry (GMRT) real data | 1,823 × 2,063 · every 100 m | 151 ms | 23.5 ms | 611 ms | 612 ms | 3.16 s▲ | 662 ms | 2.71 s | 76.3 ms | 4.0× | 3.2× |
| Full SRTM 1-degree elevation tile | 3,601 × 3,601 · 25 | 74.2 ms | 6.75 ms | 436 ms | 432 ms | 822 ms | 1.28 s | 106 ms | 91.0 ms | 5.8× | 13× |
| National-scale terrain contours | 8,000 × 8,000 · 25 levels (interval 160) | 245 ms | 13.9 ms | 1.78 s | 1.76 s | 3.93 s | 6.29 s | 265 ms | 261 ms | 7.2× | 19× |
Median wall-clock time per full extraction, in-process, identical in-memory grid and iso-levels for every tool, each in its fastest documented configuration; lower is better. All line tools return assembled polylines. "Fastest overall" compares our best (1 or 48 threads) with the best result of any other library at any thread count; the shaded cell is that library. Measured November 2026 on Intel(R) Xeon(R) Platinum 8488C (48 cores / 96 threads) — AWS EC2 c7i.metal-24xl (dedicated bare-metal server, no hypervisor); Linux-7.0.0-1018-aws-x86_64-with-glibc2.39; turbo disabled; governor performance; THP never. ▲ marks a time that varied more than 5% from run to run; it is used as measured. Methodology.
Exact configuration of each library
- GDAL 3.14-dev (master) — Both versions built from source with identical options. callback = pure computation, points copied into a result buffer (as any caller must); generate_ex = native API into an in-memory layer (native result type), the layer reset before each call outside the clock. Published value = faster of the two. variant generate_ex {"api": "GDALContourGenerateEx (in-memory layer)"}
- GDAL 3.13.3 — Both versions built from source with identical options. callback = pure computation, points copied into a result buffer (as any caller must); generate_ex = native API into an in-memory layer (native result type), the layer reset before each call outside the clock. Published value = faster of the two. variant generate_ex {"api": "GDALContourGenerateEx (in-memory layer)"}
- VTK Flying Edges (1 thread) — vtkImageData + filter pipeline built in prepare (zero-copy wrap, O(1)). vtkStripper joins segments into polylines (required for like-for-like output; MaximumLength unlimited so lines are fully joined) and is timed. variant sequential {"backend": "Sequential", "threads": 1}
- ContourPy (serial) — variant serial_reused {"name": "serial", "line_type": "LineType.ChunkCombinedOffset", "reuse_generator": true}
- VTK Flying Edges (best SMP backend × threads) — vtkImageData + filter pipeline built in prepare (zero-copy wrap, O(1)). vtkStripper joins segments into polylines (required for like-for-like output; MaximumLength unlimited so lines are fully joined) and is timed. variant smp {"backend": "STDThread", "threads": 4}
- ContourPy (threaded, best threads × chunks) — variant threaded_reused {"name": "threaded", "line_type": "LineType.ChunkCombinedOffset", "thread_count": 8, "chunk_count": [4, 4], "reuse_generator": true}
The margin grows with the number of levels. Tools that march the grid once per level, such as ContourPy and scikit-image, slow down linearly with every extra contour interval. isosweep’s sweep finds all levels in one pass, and its cost follows the length of the contours it emits, not cells × levels.
More than speed
- Closed contours that know which side is up. Every closed contour carries
a
hillflag computed from the field itself (summit vs depression), plus anopenflag for lines cut by the raster edge or NoData. Depression contours and hypsometric fills need no extra pass and no re-sampling. - A command-line tool too.
isosweep-contourreads any GDAL raster and writes GeoPackage or GeoJSON: contour lines, filled bands or per-level polygons. Rasters that fit in memory use the multi-threaded engine measured above; larger ones are streamed in blocks of rows, on all cores, in memory bounded by the raster’s width, so a national LiDAR mosaic doesn’t have to be tiled first. - NoData handled like GDAL. Voids cut contours cleanly at their edge, and rotated geotransforms are honoured.
- Embeddable. A dependency-free C library. GDAL is used only by the CLI for file formats, so the engine itself drops into a tile server, a mobile map or an appliance.
isosweep-contour --interval 20 dem.tif -o contours.gpkgWhere GDAL is still the right tool
GDAL reads and writes every format under the sun, and gdal_contour is free.
If contouring is an occasional step in a desktop workflow, it is fine. isosweep
pays off when contouring is recurring, large, or latency-sensitive: national
mapping production, LiDAR deliverables, re-contouring at many intervals, or
contouring inside a service. Commercial desktop tools (ArcGIS Pro, whose Contour
tool is documented to use at most four cores; Global Mapper; FME; Surfer) are not
benchmarked here. Commercial licences commonly restrict publishing benchmark
results, so we suggest evaluating them side by side on your own data.