Simplify polygons for a map, if there are many of them
Source:R/utils_map_size.R
map_shapes_simplified.RdSimplify polygons for a map, if there are many of them
Arguments
- shapes
spatial data.frame of polygons
- dTolerance_meters
Simplification tolerance in projected map metres, passed to
sf::st_simplify()asdToleranceafter projection.
Details
If there are more than default_max_shapes_map_unsimplified polygons
(see map_size_setting()), each is simplified with sf::st_simplify(),
which keeps the map smaller and faster. This affects only what is drawn, not any analysis.
Simplification is performed in a metre-based projected CRS (EPSG:3857),
then transformed back to the input CRS. This keeps the tolerance in metres
regardless of sf::sf_use_s2() or the input CRS units. Shapes without a
known CRS are returned unchanged. EPSG:3857 distances are map-plane metres,
not geodesic ground distances (distortion increases at high latitudes).
If simplifying fails, the polygons are returned unchanged.