knitr::opts_chunk$set( comment = "#>", collapse = TRUE, warning = FALSE, message = FALSE )
port of the JS library geojson-rewind, with ports of parts of the JS libraries geojson-area and wgs84 included
install.packages("devtools") devtools::install_github("ropenscilabs/geojsonrewind")
library("geojsonrewind")
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]])
the value is negative if ring is oriented counterclockwise
ring_area(x = rev(x$coordinates[[1]]))
when outer = TRUE
, clockwise
rewind(x)
when outer = FALSE
, counterclockwise
rewind(x, outer = FALSE)
geojsonrewind
in R doing citation(package = 'geojsonrewind')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.