knitr::opts_chunk$set( comment = "#>", collapse = TRUE, warning = FALSE, message = FALSE )
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:
rg_position
- random position (lon, lat)geo_point
- random GeoJSON pointgeo_linestring
- random GeoJSON linestringgeo_polygon
- random GeoJSON polygonwkt_point
- random WKT pointwkt_linestring
- random WKT linestringwkt_polygon
- random WKT polygonhttps://docs.ropensci.org/randgeo/
Stabler CRAN version
install.packages("randgeo")
Development version
devtools::install_github("ropensci/randgeo")
library("randgeo")
set.seed(42)
rg_position()
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))
Random point
wkt_point()
Random linestring
wkt_linestring()
Random polygon
wkt_polygon()
randgeo
in R doing citation(package = 'randgeo')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.