mregions

knitr::opts_chunk$set(
  warning = FALSE, 
  message = FALSE,
  collapse = TRUE,
  comment = "#>"
) 

Build Status codecov.io rstudio mirror downloads cran version

mregions - Get data from https://www.marineregions.org

Some data comes from the Flanders Marine Institute (VLIZ) geoserver

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:

Install

install.packages("mregions")
install.packages("sf")

Development version

devtools::install_github("ropensci/mregions")

Load Libraries

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.

ecoregions_geoJSON <- mr_geojson(key = "Ecoregions:ecoregions", maxFeatures = 250)
length(ecoregions_geoJSON$features)

Plot Data

leaflet() %>%
  addProviderTiles(provider = 'OpenStreetMap') %>%
  addGeoJSON(geojson = ecoregions_geoJSON$features) %>%
  fitBounds(-160,-52,160,60)

map1

example 2: Maritime Boundaries (EEZ)

Get Data

eezboundaries_geoJSON <- mr_geojson(key = "MarineRegions:eez", maxFeatures = 1)

Plot Data

leaflet() %>%
  addProviderTiles(provider = 'OpenStreetMap') %>%
  addGeoJSON(geojson = eezboundaries_geoJSON$features) %>%
  fitBounds(39,11,83,-10)

map2

Get Shape

example 1: Marine Ecoregions of the World (MEOW)

Select region

ecoregions_shp <- mr_shp(key = "Ecoregions:ecoregions", maxFeatures = 250)
class(ecoregions_shp)

Plot data

leaflet() %>%
  addProviderTiles(provider = 'OpenStreetMap') %>%
  addPolygons(data = ecoregions_shp)%>%
  fitBounds(-182,-79,178,83)

map4

example 2: Maritime Boundaries (EEZ)

Select region

eezboundaries_shp <- mr_shp(key = "MarineRegions:eez", maxFeatures = 1)

Plot data

leaflet() %>%
  addProviderTiles(provider = 'OpenStreetMap') %>%
  addPolygons(data = eezboundaries_shp)

map5

Convert to WKT

example 1: Marine Ecoregions of the World (MEOW)

From GeoJSON

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)

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

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

highseas_info <- mr_geo_code(place = "High Seas")
class(highseas_info)
str(highseas_info)

Contributors

Meta

rofooter



ropenscilabs/mregions documentation built on Feb. 28, 2024, 9:21 p.m.