randgeo: random WKT and GeoJSON

knitr::opts_chunk$set(
  comment = "#>",
  collapse = TRUE,
  warning = FALSE,
  message = FALSE
)

Project Status: Active – The project has reached a stable, usable state and is being actively developed. cran checks R-check codecov.io rstudio mirror downloads cran version

randgeo generates random points and shapes in GeoJSON and WKT formats for use in examples, teaching, or statistical applications.

Points and shapes are generated in the long/lat coordinate system and with appropriate spherical geometry; random points are distributed evenly across the globe, and random shapes are sized according to a maximum great-circle distance from the center of the shape.

randgeo was adapted from https://github.com/tmcw/geojson-random to have a pure R implementation without any dependencies as well as appropriate geometry. Data generated by randgeo may be processed or displayed of with packages such as sf, wicket, geojson, wellknown, geojsonio, or lawn.

Package API:

Docs

https://docs.ropensci.org/randgeo/

Install

Stabler CRAN version

install.packages("randgeo")

Development version

devtools::install_github("ropensci/randgeo")
library("randgeo")
set.seed(42)

Generate a random position

rg_position()

Generate random GeoJSON

Random point - evenly distributed across the sphere. The bbox option allows you to limit points to within long/lat bounds.

geo_point()

Random linestring - starting from a random point, with default maximum segment length and maximum rotation between two segments.

geo_linestring()

Random polygon - centered on a random point, with default maximum size

geo_polygon()

Visualize your shapes with lawn.

lawn::view(jsonlite::toJSON(geo_polygon(count = 4), auto_unbox = TRUE))

map

Generate random WKT

Random point

wkt_point()

Random linestring

wkt_linestring()

Random polygon

wkt_polygon()

Contributors

Meta

rofooter



ropensci/randgeo documentation built on Sept. 12, 2022, 2:01 p.m.