Learn R Programming

mregions (version 0.1.8)

mregions-package: Marine regions data from Marineregions

Description

Tools to get marine regions data from https://www.marineregions.org/. Includes tools to get region metadata, as well as data in 'GeoJSON' format, as well as Shape files. Use cases include using data downstream to visualize 'geospatial' data by marine region, mapping variation among different regions, and more.

Arguments

Use-cases

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

Details

mregions gets data from https://www.marineregions.org/

Examples

Run this code
# NOT RUN {
## GeoJSON
### Get region
res <- mr_geojson(key = "Morocco:dam")

### Plot data
if (!requireNamespace("leaflet")) {
 install.packages("leaflet")
}
library('leaflet')
leaflet() %>%
  addProviderTiles(provider = 'OpenStreetMap') %>%
  addGeoJSON(geojson = res$features) %>%
  setView(-3.98, 35.1, zoom = 11)

## Shape
### Get region
res <- mr_shp(key = "MarineRegions:eez_iho_union_v2")
library('leaflet')
leaflet() %>%
  addProviderTiles(provider = 'OpenStreetMap') %>%
  addPolygons(data = res)

## Convert to WKT
### From geojson
res <- mr_geojson(key = "Morocco:dam")
mr_as_wkt(res, fmt = 5)

### From shp object (`SpatialPolygonsDataFrame`) or file, both work
mr_as_wkt(mr_shp(key = "Morocco:dam", read = FALSE))
## spatial object to wkt
mr_as_wkt(mr_shp(key = "Morocco:dam", read = TRUE))
# }

Run the code above in your browser using DataLab