Return a FeatureCollection with N number of features with random coordinates

gr_point(n = 10, bbox = NULL)

gr_position(bbox = NULL)

gr_polygon(n = 1, vertices = 10, max_radial_length = 10, bbox = NULL)

Arguments

n

(integer) Number of features to create. Default: 10 (points), 1 (polygons)

bbox

(numeric) A bounding box of length 4, of the form west, south, east, north order. By default, no bounding box is passed in.

vertices

(integer) Number coordinates each Polygon will contain. Default: 10

max_radial_length

(integer) Maximum number of decimal degrees latitude or longitude that a vertex can reach out of the center of the Polygon. Default: 10

Value

A data-FeatureCollection for point and polygon, or numeric vector for position.

Details

These functions create either random points, polygons, or positions (single long/lat coordinate pairs).

References

https://github.com/mapbox/geojson-random

See also

Examples

# Random points gr_point(5)
#> <FeatureCollection> #> Bounding box: -101.2 -81.4 98.2 -9.7 #> No. features: 5 #> No. points: 10 #> Properties: NULL
gr_point(10)
#> <FeatureCollection> #> Bounding box: -123.1 -84.0 174.9 80.4 #> No. features: 10 #> No. points: 20 #> Properties: NULL
gr_point(1000)
#> <FeatureCollection> #> Bounding box: -179.3 -89.7 179.6 89.9 #> No. features: 1000 #> No. points: 2000 #> Properties: NULL
## with bounding box gr_point(5, c(50, 50, 60, 60))
#> <FeatureCollection> #> Bounding box: 51.4 51.0 59.1 53.5 #> No. features: 5 #> No. points: 10 #> Properties: NULL
# Random positions gr_position()
#> [1] -43.64597 -86.61728
## with bounding box gr_position(c(0, 0, 10, 10))
#> [1] 9.190374 2.554662
# Random polygons ## number of polygons, default is 1 polygon gr_polygon()
#> <FeatureCollection> #> Bounding box: -91.4 75.7 -78.6 89.3 #> No. features: 1 #> No. points: 22 #> Properties: NULL
gr_polygon(5)
#> <FeatureCollection> #> Bounding box: -136.7 -66.8 146.9 78.5 #> No. features: 5 #> No. points: 110 #> Properties: NULL
## number of vertices, 3 vs. 100 gr_polygon(1, 3)
#> <FeatureCollection> #> Bounding box: -38.4 52.5 -28.8 53.3 #> No. features: 1 #> No. points: 8 #> Properties: NULL
gr_polygon(1, 100)
#> <FeatureCollection> #> Bounding box: -41.5 4.3 -22.5 21.8 #> No. features: 1 #> No. points: 202 #> Properties: NULL
## max radial length, compare the following three gr_polygon(1, 10, 5)
#> <FeatureCollection> #> Bounding box: 67.1 -40.0 75.0 -35.1 #> No. features: 1 #> No. points: 22 #> Properties: NULL
gr_polygon(1, 10, 30)
#> <FeatureCollection> #> Bounding box: -20.2 20.9 14.5 48.1 #> No. features: 1 #> No. points: 22 #> Properties: NULL
gr_polygon(1, 10, 100)
#> <FeatureCollection> #> Bounding box: -7.0 -86.5 132.6 41.9 #> No. features: 1 #> No. points: 22 #> Properties: NULL
## use a bounding box gr_polygon(1, 5, 5, c(50, 50, 60, 60))
#> <FeatureCollection> #> Bounding box: 48.9 51.2 55.0 54.1 #> No. features: 1 #> No. points: 12 #> Properties: NULL