An open API service indexing awesome lists of open source software.

https://github.com/mdsumner/sfdct

Constrained Delaunay triangulation for simple features
https://github.com/mdsumner/sfdct

Last synced: 4 months ago
JSON representation

Constrained Delaunay triangulation for simple features

Awesome Lists containing this project

README

          

---
output: github_document
---

[![R build status](https://github.com/hypertidy/sfdct/workflows/R-CMD-check/badge.svg)](https://github.com/hypertidy/sfdct/actions)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/sfdct)](https://cran.r-project.org/package=sfdct)
[![R build status](https://github.com/hypertidy/sfdct/workflows/pkgdown/badge.svg)](https://github.com/hypertidy/sfdct/actions)
[![R build status](https://github.com/hypertidy/sfdct/workflows/test-coverage/badge.svg)](https://github.com/hypertidy/sfdct/actions)


```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```

# sfdct

The goal of sfdct is to provide constrained triangulation of simple features.

## Limitations

Triangulation is performed with respect to the vertices and edges *per-feature*. This means that each output feature will
be composed of triangles that align to all input edges. This will also correspond to the outer hull of any lines or polygons. In a GEOMETRYCOLLECTION the same alignment only applies to geometries individually within the collection, so lines and polygons and point sets are
all triangulated as if they were independent.

A future release will triangulate the GEOMETRYCOLLECTION as it it were one set of edges and vertices. This will also allow an entire data set
to be triangulated as one.

It's not yet clear to me how to best maintain the original feature identity for the "entire data set" case, or if this even matters. Please get in touch if you are interested!

More general structures for working with grouped simplicial complex data structures are in the works, but aligning with simple features in this package provides a useful illustration of these nuances and how far we can push the standard tools.

## Example

This is a basic example which shows you how to decompose a MULTIPOLYGON `sf` data frame object into a GEOMETRYCOLLECTION `sf` data frame object made of triangles:

```{r example}
library(sf)
library(sfdct)
nc <- read_sf(system.file("shape/nc.shp", package="sf"), quiet = TRUE)
(nc_triangles <- ct_triangulate(nc[1:5, c("NAME")]))

(asub <- st_geometry(nc_triangles)[[4]] )

```

Denser triangles, and optionally `D` for ensuring Delaunay criterion is met.

```{r}
st_geometry(ct_triangulate(nc[4, ], a = 0.0007, D = TRUE))

```

See the vignettes for more examples.

If you are interested in development in this area see [anglr package](https://github.com/hypertidy/anglr) a workhorse for triangulating spatial data into meshes. A development project [laridae](https://github.com/hypertidy/laridae) aims to provide a more powerful facility
for finite element decomposition for complex shapes using CGAL. There is an ear-clipping version, from the [decido package](https://CRAN.r-project.org/package=decido) in [silicate](https://github.com/hypertidy/silicate)

---

Please note that this project is released with a [Contributor Code of Conduct](https://github.com/hypertidy/sfdct/blob/master/CONDUCT.md). By participating in this project you agree to abide by its terms.