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 point
  • geo_linestring - random GeoJSON linestring
  • geo_polygon - random GeoJSON polygon
  • wkt_point - random WKT point
  • wkt_linestring - random WKT linestring
  • wkt_polygon - random WKT polygon


Stabler CRAN version


Development version


Generate a random position

Generate random GeoJSON

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

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

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

Visualize your shapes with lawn.

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



  • Scott Chamberlain
  • Noam Ross
  • Samuel Bosch