-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
70 lines (44 loc) · 3.03 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
<!-- badges: start -->
[![R-CMD-check](https://github.com/hypertidy/sfdct/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/hypertidy/sfdct/actions/workflows/R-CMD-check.yaml)
[![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)
<!-- badges: end -->
```{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.