-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
77 lines (49 loc) · 1.73 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
---
title: "cofbb"
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
This R package serves the spatial bounding box definitions we use in the Record Lab.
### Requirements
+ [R v4+](https://www.r-project.org/)
+ [rlang](https://CRAN.R-project.org/package=rlang)
+ [dplyr](https://CRAN.R-project.org/package=dplyr)
+ [sf](https://CRAN.R-project.org/package=sf)
### Suggested
+ [leaflet](https://CRAN.R-project.org/package=leaflet)
### Installation
```
remotes::install_github("BigelowLab/cofbb")
```
### Usage
Retrieve a table of all known bounding boxes.
```{r get_table}
cofbb::get_table()
```
Retrieve one or more regions by name as a table.
```{r get_bb_table}
cofbb::get_bb(c("world", "nwa2"), form = "table")
```
Retrieve one or more regions by name as a list of vector in `[xmin, xmax, ymin, ymax]` order.
```{r get_bb_list}
cofbb::get_bb(c("world", "nwa2"), form = "bb")
```
Or retrieve just one as a vector
```{r get_bb_vector}
cofbb::get_bb("gom", form = "bb")
```
### Ancillary Functions
There are also functions for making `[-180, 180]` <-> `[0,360]` longitude transformations (`to_180BB()`, `to_360BB()`), splitting bounding boxes (`bb_split()`) and determining if a box straddles a particular line of longitude (`bb_straddles()`).
### [sf](https://CRAN.R-project.org/package=sf)
You can also retrieve bounding boxes as a data frame of one or more [sf](https://CRAN.R-project.org/package=sf) POLYGON objects.
```{r get_sf}
x <- cofbb::get_bb(c("gosl", "gom", "nwa2"), form = "sf")
x
```
If you have [leaflet](https://CRAN.R-project.org/package=leaflet) installed you can draw a pretty map (otherwise a boring map is drawn.)
```
plot_bb(x)
```
![leaflet](inst/images/leaflet.png)