This repository has been archived by the owner on Sep 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
README-NOT.Rmd
209 lines (147 loc) · 5.43 KB
/
README-NOT.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
---
output: github_document
---
mregions
========
```{r setup, include=FALSE}
knitr::opts_chunk$set(
warning = FALSE,
message = FALSE,
collapse = TRUE,
comment = "#>"
)
```
<!-- [![cran -->
<!-- checks](https://badges.cranchecks.info/worst/mregions.svg)](https://cran.r-project.org/web/checks/check_results_mregions.html) -->
[![Build Status](https://app.travis-ci.com/ropensci/mregions.svg)](https://app.travis-ci.com/ropensci/mregions)
[![codecov.io](https://codecov.io/github/ropensci/mregions/coverage.svg?branch=master)](https://app.codecov.io/github/ropensci/mregions?branch=master)
[![rstudio mirror downloads](http://cranlogs.r-pkg.org/badges/mregions?color=FAB657)](https://github.com/r-hub/cranlogs.app)
[![cran version](http://www.r-pkg.org/badges/version/mregions)](https://cran.r-project.org/package=mregions)
[![](https://badges.ropensci.org/53_status.svg)](https://github.com/ropensci/software-review/issues/53)
`mregions` - Get data from <https://www.marineregions.org>
Some data comes from the [Flanders Marine Institute (VLIZ) geoserver](http://geo.vliz.be/geoserver/web/)
`mregions` is useful to a wide diversity of R users because you get access to all of the
data MarineRegions has, which can help in a variety of use cases:
* Visualize marine regions alone
* Visualize marine regions with associated data paired with analysis
* Use marine region geospatial boundaries to query data providers (e.g., OBIS (<https://www.obis.org>))
* Geocode - get geolocation data from place names
* Reverse Geocode - get place names from geolocation data
## Install
```{r eval=FALSE}
install.packages("mregions")
install.packages("sf")
```
Development version
```{r eval=FALSE}
devtools::install_github("ropensci/mregions")
```
Load Libraries
```{r}
library("mregions")
library("sf")
# helper library
library("leaflet")
```
## Get GeoJSON
#### example 1: Marine Ecoregions of the World (MEOW)
**Get Data**
Keys accessible from the [Flanders Marine Institute (VLIZ) geoserver](http://geo.vliz.be/geoserver/web/).
```{r, eval=TRUE}
ecoregions_geoJSON <- mr_geojson(key = "Ecoregions:ecoregions", maxFeatures = 250)
length(ecoregions_geoJSON$features)
```
**Plot Data**
```{r eval=FALSE}
leaflet() %>%
addProviderTiles(provider = 'OpenStreetMap') %>%
addGeoJSON(geojson = ecoregions_geoJSON$features) %>%
fitBounds(-160,-52,160,60)
```
![map1](man/figures/leaf_ecoregions.png)
### example 2: Maritime Boundaries (EEZ)
**Get Data**
```{r}
eezboundaries_geoJSON <- mr_geojson(key = "MarineRegions:eez", maxFeatures = 1)
```
**Plot Data**
```{r eval=FALSE}
leaflet() %>%
addProviderTiles(provider = 'OpenStreetMap') %>%
addGeoJSON(geojson = eezboundaries_geoJSON$features) %>%
fitBounds(39,11,83,-10)
```
![map2](man/figures/leaf_eez.png)
## Get Shape
#### example 1: Marine Ecoregions of the World (MEOW)
**Select region**
```{r, eval=TRUE}
ecoregions_shp <- mr_shp(key = "Ecoregions:ecoregions", maxFeatures = 250)
class(ecoregions_shp)
```
**Plot data**
```{r eval=FALSE}
leaflet() %>%
addProviderTiles(provider = 'OpenStreetMap') %>%
addPolygons(data = ecoregions_shp)%>%
fitBounds(-182,-79,178,83)
```
![map4](man/figures/leaf_ecoregions.png)
#### example 2: Maritime Boundaries (EEZ)
**Select region**
```{r, eval=FALSE}
eezboundaries_shp <- mr_shp(key = "MarineRegions:eez", maxFeatures = 1)
```
**Plot data**
```{r eval=FALSE}
leaflet() %>%
addProviderTiles(provider = 'OpenStreetMap') %>%
addPolygons(data = eezboundaries_shp)
```
![map5](man/figures/leaf_eez.png)
## Convert to WKT
#### example 1: Marine Ecoregions of the World (MEOW)
**From GeoJSON**
```{r eval=TRUE}
ecoregions_geoJSON <- mr_geojson(key = "Ecoregions:ecoregions", maxFeatures = 250)
ecoregions_wkt_fromGeoJSON <- mr_as_wkt(ecoregions_geoJSON, fmt = 2)
class(ecoregions_wkt_fromGeoJSON)
ecoregions_wkt_fromGeoJSON[1]
```
**From shp object (using the sf package)**
```{r eval=TRUE}
ecoregions_shp <- mr_shp(key = "Ecoregions:ecoregions", maxFeatures = 250)
ecoregions_shp_geom <- st_geometry(ecoregions_shp)
ecoregions_wkt_fromshp <- st_as_text(ecoregions_shp_geom)
ecoregions_wkt_fromshp[1]
```
*More detailed example using the Black Sea Ecoregion only*
```{r, eval=TRUE}
ecoregions_blacksea <- subset(ecoregions_shp, ecoregions_shp$ecoregion == "Black Sea")
class(ecoregions_blacksea)
ecoregions_blacksea_geom <- st_geometry(ecoregions_blacksea)
class(ecoregions_blacksea_geom)
ecoregions_blacksea_wkt <- st_as_text(ecoregions_blacksea_geom)
class(ecoregions_blacksea_wkt)
ecoregions_blacksea_wkt
```
## Gazetteer Record by Name
#### example: High Seas
```{r, eval=TRUE}
highseas_info <- mr_geo_code(place = "High Seas")
class(highseas_info)
str(highseas_info)
```
## Contributors
* [Scott Chamberlain](https://github.com/sckott)
* [Francois Michonneau](https://github.com/fmichonneau)
* [Pieter Provoost](https://github.com/pieterprovoost)
* [Michael Sumner](https://github.com/mdsumner)
* [Lennert Schepers](https://github.com/LennertSchepers)
* [Salvador Fernandez](https://github.com/salvafern)
## Meta
* Please [report any issues or bugs](https://github.com/ropensci/mregions/issues).
* License: MIT
* Get citation information for `mregions` in R doing `citation(package = 'mregions')`
* Please note that this project is released with a [Contributor Code of Conduct](https://github.com/ropensci/mregions/blob/master/CONDUCT.md). By participating in this project you agree to abide by its terms.
[![rofooter](https://ropensci.org/public_images/github_footer.png)](https://ropensci.org)