Skip to content

Commit

Permalink
as/polygonize_docs (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 authored May 15, 2024
1 parent dc60abd commit 0be82ff
Showing 1 changed file with 9 additions and 6 deletions.
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

0 comments on commit 0be82ff

Please sign in to comment.