Skip to content

points_geometry

Ben Tupper edited this page Dec 22, 2022 · 3 revisions

Geometry

Triangulation of a set of points

It can be useful to compute a simple Delaunay triangulation. Here you get to chose one of two methods. The default it to use the geometry::delaunayn() package. The method produces a table with POLYGON geometry per row. The other option uses [sf:st_triangulate()] whcih yields a single GEOMETRYCOLLECTION. Using the default allows you to compute some simple values (such as mean of values at vertices, etc).

pts <- sf::read_sf(system.file("datasets/penbay-points.gpkg", package = 'twinkle'))
mesh <- points_to_mesh(pts, method = 'geometry')
sst <- stars::read_stars(system.file("datasets/20140601-20140630-sst.tif", package = "twinkle"))
plot(sst[,,,1],
     main = "sst 2014-01-01",
     reset = FALSE,
     add.geom = list(sf::st_geometry(pts), col = 'blue', pch = 19))
plot(sf::st_geometry(mesh), add = TRUE, border = 'orange')

Convex hull of a set of points

The convex hull is the shape that enclose the extreme extents of a collection of points. Think of it as rubber band stretched around the points.

pts <- sf::read_sf(system.file("datasets/penbay-points.gpkg", package = 'twinkle'))
    chull <- points_to_convexhull(pts)
    sst <- stars::read_stars(system.file("datasets/20140601-20140630-sst.tif", package = "twinkle"))
    plot(sst[,,,1],
      main = "sst 2014-01-01",
      reset = FALSE,
      add.geom = list(sf::st_geometry(pts), col = 'blue', pch = 19))
    plot(sf::st_geometry(chull), add = TRUE, border = 'orange')

Clone this wiki locally