Learn R Programming

lawn (version 0.5.0)

lawn_tesselate: Tesselate

Description

Tesselates a data-Polygon into a data-FeatureCollection of triangles using earcut (https://github.com/mapbox/earcut)

Usage

lawn_tesselate(polygon, lint = FALSE)

Arguments

polygon
lint

(logical) Lint or not. Uses geojsonhint. Takes up increasing time as the object to get linted increases in size, so probably use by default for small objects, but not for large if you know they are good geojson objects. Default: FALSE

Value

A data-FeatureCollection

See Also

Other assertions: lawn_circle, lawn_dissolve

Examples

Run this code
# NOT RUN {
poly <- '{
 "type": "Feature",
  "properties": {
    "fill": "#0f0"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-46.738586, -23.596711],
      [-46.738586, -23.458207],
      [-46.560058, -23.458207],
      [-46.560058, -23.596711],
      [-46.738586, -23.596711]
    ]]
  }
}'
lawn_tesselate(poly)

xx <- jsonlite::fromJSON(lawn_data$polygons_within, FALSE)
lawn_tesselate(xx$features[[1]])
# }
# NOT RUN {
lawn_tesselate(xx$features[[1]]) %>% view
lawn_tesselate(poly) %>% view
# }

Run the code above in your browser using DataLab