This repository has been archived by the owner on Sep 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME.Rmd
144 lines (103 loc) · 3.9 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
randgeo: random WKT and GeoJSON
===============================
```{r echo=FALSE}
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.](https://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
[![cran checks](https://cranchecks.info/badges/worst/randgeo)](https://cranchecks.info/pkgs/randgeo)
[![R-check](https://github.com/ropensci/randgeo/workflows/R-check/badge.svg)](https://github.com/ropensci/randgeo/actions?query=workflow%3AR-check)
[![codecov.io](https://codecov.io/github/ropensci/randgeo/coverage.svg?branch=master)](https://codecov.io/github/ropensci/randgeo?branch=master)
[![rstudio mirror downloads](https://cranlogs.r-pkg.org/badges/randgeo?color=C9A115)](https://github.com/metacran/cranlogs.app)
[![cran version](https://www.r-pkg.org/badges/version/randgeo)](https://cran.r-project.org/package=randgeo)
**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**](https://cran.r-project.org/package=sf),
[**wicket**](https://cran.r-project.org/package=wicket),
[**geojson**](https://cran.r-project.org/package=geojson),
[**wellknown**](https://cran.r-project.org/package=wellknown),
[**geojsonio**](https://cran.r-project.org/package=geojsonio), or
[**lawn**](https://cran.r-project.org/package=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
## Docs
<https://docs.ropensci.org/randgeo/>
## Install
Stabler CRAN version
```{r eval=FALSE}
install.packages("randgeo")
```
Development version
```{r eval=FALSE}
devtools::install_github("ropensci/randgeo")
```
```{r}
library("randgeo")
```
```{r, include=FALSE}
set.seed(42)
```
## Generate a random position
```{r}
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.
```{r}
geo_point()
```
Random linestring - starting from a random point, with default maximum segment
length and maximum rotation between two segments.
```{r}
geo_linestring()
```
Random polygon - centered on a random point, with default maximum size
```{r}
geo_polygon()
```
Visualize your shapes with **lawn**.
```{r eval=FALSE}
lawn::view(jsonlite::toJSON(geo_polygon(count = 4), auto_unbox = TRUE))
```
![map](https://github.com/ropensci/randgeo/raw/master/tools/plot.png)
## Generate random WKT
Random point
```{r}
wkt_point()
```
Random linestring
```{r}
wkt_linestring()
```
Random polygon
```{r}
wkt_polygon()
```
## Contributors
* Scott Chamberlain
* Noam Ross
* Samuel Bosch
## Meta
* Please [report any issues or bugs](https://github.com/ropensci/randgeo/issues).
* License: MIT
* Get citation information for `randgeo` in R doing `citation(package = 'randgeo')`
* Please note that this package is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By contributing to this project, you agree to abide by its terms.
[![rofooter](https://ropensci.org/public_images/github_footer.png)](https://ropensci.org)