This function allows you to reduce the number of vertices used to encode the geometry while attempting to keep the geometry as close to the original as possible. You can choose between different cost functions and stop conditions in order to fine tune the procedure.
Usage
simplify_poly(
poly,
cost = "squared",
stop = "below count ratio",
cost_ratio = 0.5,
stop_threshold = 0.5
)
Arguments
- poly
A
polyclid_polygon
orpolyclid_polyline
- cost
The cost function to use. See details.
- stop
The stop condition to use for terminating the simplification. See details.
- cost_ratio
The ratio to use if
cost = "hybrid squared
- stop_threshold
The threshold to use with the stop condition
See also
Other boundary resolution:
densify_poly()
Examples
poly <- polyclid::denmark()
plot(poly)
poly_s <- simplify_poly(poly)
# Number of original vertices
sum(cardinality(poly))
#> [1] 2165
# Number after simplification
sum(cardinality(poly_s))
#> [1] 1079
# Close to same visual
plot(poly_s)
# Plot Jutland using only 20 vertices
plot(simplify_poly(poly[1], stop = "below count", stop_threshold = 20))
euclid_plot(poly[1], lty = 2, border = "red")