Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jolars/polylabelr
Find the Pole of Inaccessibility (Visual Center) of a Polygon
https://github.com/jolars/polylabelr
Last synced: 2 days ago
JSON representation
Find the Pole of Inaccessibility (Visual Center) of a Polygon
- Host: GitHub
- URL: https://github.com/jolars/polylabelr
- Owner: jolars
- License: other
- Created: 2018-10-23T06:36:46.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-27T18:39:55.000Z (almost 4 years ago)
- Last Synced: 2024-10-26T23:12:21.783Z (16 days ago)
- Language: C++
- Homepage: https://jolars.github.io/polylabelr/
- Size: 144 KB
- Stars: 17
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# polylabelr[![R build status](https://github.com/jolars/polylabelr/workflows/R-CMD-check/badge.svg)](https://github.com/jolars/polylabelr/actions)
[![Travis build status](https://travis-ci.com/jolars/polylabelr.svg?branch=master)](https://travis-ci.com/jolars/polylabelr)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/jolars/polylabelr?branch=master&svg=true)](https://ci.appveyor.com/project/jolars/polylabelr)
[![Coverage status](https://codecov.io/gh/jolars/polylabelr/branch/master/graph/badge.svg)](https://codecov.io/github/jolars/polylabelr?branch=master)
[![CRAN status](https://www.r-pkg.org/badges/version/polylabelr)](https://cran.r-project.org/package=polylabelr)**polylabelr** is an R wrapper for the
[polylabel package](https://github.com/mapbox/polylabel)
from [Mapbox](https://www.mapbox.com/). It currently contains a single function,
`poi()` that finds the *pole of inaccessibility* of a polygon, which usually
makes for a good place to put a label on a polygon---hence the name.## Usage
```{r}
# a concave polygon
x <- c(0, 4, 1, 6, 7, 7, 0, 0)
y <- c(0, 0, 1, 2, 1, 3, 2, 0)# locate the pole of inaccessibility
p <- polylabelr::poi(x, y, precision = 0.01)plot.new()
plot.window(range(x, na.rm = TRUE), range(y, na.rm = TRUE))
polypath(x, y, col = "grey", border = FALSE)
points(p)
```## Installation
### CRAN version
```{r, eval = FALSE}
install.packages("polylabelr")
```### Development version
```{r, eval = FALSE}
remotes::install_github("jolars/polylabelr")
```## Modifications
The source code from [polylabel](https://github.com/mapbox/polylabel)
and [geometry.hpp](https://github.com/mapbox/geometry.hpp/) has been
modified in a few ways to compile properly with c++11 using the
standard flags required by CRAN policies. polylabel has also
been modified to return the distance from the chosen point to the
enclosing polygon, in case it is of value to users.## Versioning
**polylabelr** uses [semantic versioning](https://semver.org/).