enforce polygon ring winding order for geojson
R
Latest commit 30dd50f Oct 26, 2016 @sckott sckott fix readme mistake
Permalink
Failed to load latest commit information.
R add description field to pkg level man file, bumpd dev ver Oct 26, 2016
man add description field to pkg level man file, bumpd dev ver Oct 26, 2016
tests first commit Oct 26, 2016
.Rbuildignore first commit Oct 26, 2016
.gitignore first commit Oct 26, 2016
.travis.yml first commit Oct 26, 2016
DESCRIPTION add description field to pkg level man file, bumpd dev ver Oct 26, 2016
LICENSE first commit Oct 26, 2016
NAMESPACE first commit Oct 26, 2016
README.Rmd
README.md fix readme mistake Oct 26, 2016
geojsonrewind.Rproj first commit Oct 26, 2016

README.md

geojsonrewind

Build Status codecov.io

port of the JS library geojson-rewind, with ports of parts of the JS libraries geojson-area and wgs84 included

Installation

install.packages("devtools")
devtools::install_github("ropenscilabs/geojsonrewind")
library("geojsonrewind")

Get ring area

x <- '{
 "type":"Polygon",
 "coordinates":[
   [[100.0,0.0],[100.0,1.0],[101.0,1.0],[101.0,0.0],[100.0,0.0]]
 ]
}'

the value is positive if ring is oriented clockwise

x <- jsonlite::fromJSON(x, FALSE)
ring_area(x = x$coordinates[[1]])
#> [1] 12391399902

the value is negative if ring is oriented counterclockwise

ring_area(x = rev(x$coordinates[[1]]))
#> [1] -12391399902

rewind

when outer = TRUE, clockwise

rewind(x)
#> {"type":"Polygon","coordinates":[[[100,0],[101,0],[101,1],[100,1],[100,0]]]}

when outer = FALSE, counterclockwise

rewind(x, outer = FALSE)
#> {"type":"Polygon","coordinates":[[[100,0],[100,1],[101,1],[101,0],[100,0]]]}

Meta

  • Please report any issues or bugs.
  • License: MIT
  • Get citation information for geojsonrewind in R doing citation(package = 'geojsonrewind')
  • Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

rofooter