Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Small changes to docs for polygonize #142

Merged
merged 2 commits into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/methods/polygonize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

export polygonize

#=
#=

The methods in this file convert a raster image into a set of polygons,
by contour detection using a clockwise Moore neighborhood method.

The resulting polygons are snapped to the boundaries of the cells of the input raster,
so they will look different from traditional contours from a plotting package.

The main entry point is the [`polygonize`](@ref) function.

```@docs
Expand Down Expand Up @@ -38,14 +41,13 @@ which would provide two distinct polyogns with holes.
```@example polygonize
polygons = polygonize(xs, ys, 0.8 .< zs .< 3.2)
```
This returns a list of `GeometryBasics.Polygon`, which can be plotted immediately,
or wrapped directly in a `GeometryBasics.MultiPolygon`. Let's see how these look:
This returns a `GI.MultiPolygon`, which is directly plottable. Let's see how these look:

```@example polygonize
f, a, p = poly(polygons; label = "Polygonized polygons", axis = (; aspect = DataAspect()))
```

Finally, let's plot the Makie contour lines on top, to see how well the polygonization worked:
Finally, let's plot the Makie contour lines on top, to see how the polygonization compares:
```@example polygonize
contour!(a, xs, ys, zs; labels = true, levels = [0.8, 3.2], label = "Contour lines")
f
Expand All @@ -67,11 +69,12 @@ Polygonize an `AbstractMatrix` of values, currently to a single class of polygon
Returns a `MultiPolygon` for `Bool` values and `f` return values, and
a `FeatureCollection` of `Feature`s holding `MultiPolygon` for all other values.


Function `f` should return either `true` or `false` or a transformation
of values into simpler groups, especially useful for floating point arrays.

If `xs` and `ys` are ranges, they are used as the pixel center points.
If they are `Vector` of `Tuple` they are used as the lower and upper bounds of each pixel.
If `xs` and `ys` are ranges, they are used as the pixel/cell center points.
If they are `Vector` of `Tuple` they are used as the lower and upper bounds of each pixel/cell.

# Keywords

Expand Down
Loading