Skip to content

Commit a752c52

Browse files
authored
Add contour line extraction via marching squares (#964) (#974)
* Add contour line extraction via marching squares (#964) New xrspatial.contour module with contours() function that extracts isolines from 2D rasters. Supports numpy, cupy, dask+numpy, and dask+cupy backends. Includes segment stitching into polylines and optional GeoDataFrame output. * Fix marching squares case table and add tests (#964) Corrected edge assignments in the marching squares lookup table. Previous table had wrong edges for most cases (e.g. case 1 used top edge instead of bottom edge). Added comprehensive test suite covering correctness, NaN handling, edge cases, backend equivalence, GeoDataFrame output, accessor integration, and closed-ring detection. * Add contours to docs and README feature matrix (#964) * Add contour extraction user guide notebook (#964) * Remove unused _MS_TABLE and _interp_edge from contour module (#964) * Rename contour notebook to 24_Contour_Lines (#964) * Add interactive contour explorer standalone example (#964) Matplotlib-based interactive app for exploring contour lines on procedural terrain. Supports click-to-add levels, scroll density control, filled contours, hillshade toggle, contour labels, index contours, and colour scheme cycling.
1 parent 2dc6bba commit a752c52

File tree

8 files changed

+1710
-0
lines changed

8 files changed

+1710
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ In the GIS world, rasters are used for representing continuous phenomena (e.g. e
257257
| Name | Description | NumPy xr.DataArray | Dask xr.DataArray | CuPy GPU xr.DataArray | Dask GPU xr.DataArray |
258258
|:-----|:------------|:------------------:|:-----------------:|:---------------------:|:---------------------:|
259259
| [Polygonize](xrspatial/polygonize.py) | Converts contiguous regions of equal value into vector polygons | ✅️ | ✅️ | ✅️ | 🔄 |
260+
| [Contours](xrspatial/contour.py) | Extracts elevation contour lines (isolines) from a raster surface | ✅️ | ✅️ | 🔄 | 🔄 |
260261

261262
--------
262263

docs/source/reference/utilities.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ Polygonize
2525

2626
xrspatial.polygonize.polygonize
2727

28+
Contours
29+
========
30+
.. autosummary::
31+
:toctree: _autosummary
32+
33+
xrspatial.contour.contours
34+
2835
Diagnostics
2936
===========
3037
.. autosummary::

0 commit comments

Comments
 (0)