### Example: Get All Marine Regions Sources Source: https://ropensci.github.io/mregions2/reference/gaz_sources.html Demonstrates how to fetch all Marine Regions sources and their details. This example shows the output format, which is a tibble with sourceID, source name, and sourceURL. ```R # This gaz_rest_sources() #> # A tibble: 704 × 3 #> sourceID source sourceURL #> #> 1 1 SAIL http://w… #> 2 2 ASFA thesaurus http://w… #> 3 4 Nationaal Instituut voor de Statistiek (NIS) / National S… http://s… #> 4 5 Oosthoek Times Wereldatlas NA #> 5 6 Lausch, E. (2000). Atlas van de oceanen: met de dieptekaa… NA #> 6 7 (2001). The Times comprehensive atlas of the world. 10th … NA #> 7 8 IHO-IOC GEBCO Gazetteer of Undersea Feature Names (2002-1… http://w… #> 8 9 BIOMARE http://w… #> 9 10 (1953). Limits of oceans and seas. 3rd edition. IHO Speci… NA #> 10 11 Nomenclature des espaces maritimes/List of maritime areas NA #> # ℹ 694 more rows # is the same as gaz_sources() #> # A tibble: 704 × 3 #> sourceID source sourceURL #> #> 1 1 SAIL http://w… #> 2 2 ASFA thesaurus http://w… #> 3 4 Nationaal Instituut voor de Statistiek (NIS) / National S… http://s… #> 4 5 Oosthoek Times Wereldatlas NA #> 5 6 Lausch, E. (2000). Atlas van de oceanen: met de dieptekaa… NA #> 6 7 (2001). The Times comprehensive atlas of the world. 10th … NA #> 7 8 IHO-IOC GEBCO Gazetteer of Undersea Feature Names (2002-1… http://w… #> 8 9 BIOMARE http://w… #> 9 10 (1953). Limits of oceans and seas. 3rd edition. IHO Speci… NA #> 10 11 Nomenclature des espaces maritimes/List of maritime areas NA #> # ℹ 694 more rows ``` -------------------------------- ### Basic visualization of 'eez' data product Source: https://ropensci.github.io/mregions2/reference/mrp_view.html This example shows how to visualize the 'eez' data product using the primary function. Ensure you have the 'leaflet' package installed for map rendering. ```R # You can pass a product name from mrp_list mrp_view('eez') ``` -------------------------------- ### Install mregions2 from GitHub Source: https://ropensci.github.io/mregions2/index.html Install the development version of the mregions2 package from GitHub. Ensure devtools is installed first. This command also builds vignettes. ```r # install.packages("devtools") devtools::install_github("ropensci/mregions2", build_vignettes = TRUE) ``` -------------------------------- ### Examples of gaz_rest_source_by_sourceid Source: https://ropensci.github.io/mregions2/reference/gaz_rest_source_by_sourceid.html Demonstrates retrieving source details for specific source IDs. ```R # \donttest{ gaz_rest_source_by_sourceid(390) #> source #> "Flanders Marine Institute (2018). Maritime Boundaries Geodatabase: Maritime Boundaries and Exclusive Economic Zones (200NM). Available online at http://www.marineregions.org https://doi.org/10.14284/312" #> url #> "http://www.marineregions.org" gaz_rest_source_by_sourceid(657) #> source #> "IHO-IOC GEBCO Gazetteer of Undersea Feature Names" #> url #> "http://www.ngdc.noaa.gov/gazetteer/" # } ``` -------------------------------- ### Install and load magrittr for pipe operator Source: https://ropensci.github.io/mregions2/index.html If using the pipe operator '%>%', install and load the 'magrittr' package. ```r # install.packages("magrittr") library(magrittr) ``` -------------------------------- ### Load Required Libraries Source: https://ropensci.github.io/mregions2/articles/mregions2-rdf.html Initial setup for working with mregions2, rdflib, and associated visualization tools. ```R library(mregions2) library(rdflib) # Use the pipe operator `%>%` library(magrittr) # For visualizing library(mapview) library(jsonlite) ``` -------------------------------- ### Install required packages for mrp_view() Source: https://ropensci.github.io/mregions2/index.html The mrp_view() function requires the 'leaflet' and 'leaflet.extras2' packages, which must be installed separately. ```r install.packages("leaflet") install.packages("leaflet.extras2") ``` -------------------------------- ### Example: Retrieve relations for a specific MRGID Source: https://ropensci.github.io/mregions2/reference/gaz_rest_relations_by_mrgid.html Demonstrates how to fetch relations for a given MRGID using the default parameters. ```R # \donttest{ gaz_rest_relations_by_mrgid(7378) #> # A tibble: 7 × 14 #> MRGID gazetteerSource placeType latitude longitude minLatitude minLongitude #> #> 1 1908 (1953). Limits of… IHO Sea … 27.0 -169. 0 118. #> 2 7378 IHO-IOC GEBCO Gaz… Trench 16.7 148. 11 142. #> 3 8316 Flanders Marine I… EEZ 6.77 150. -1.17 135. #> 4 8487 Flanders Marine I… EEZ 29.6 138. 17.1 122. #> 5 6299 IHO-IOC GEBCO Gaz… Deep 11.4 143. NA NA #> 6 48957 Flanders Marine I… EEZ 12.9 144. 11.0 141. #> 7 48980 Flanders Marine I… EEZ 18.3 146. 12.2 141. #> # ℹ 7 more variables: maxLatitude , maxLongitude , #> # preferredGazetteerName , preferredGazetteerNameLang , #> # status , accepted , precision # } ``` -------------------------------- ### List All Available Sources Source: https://ropensci.github.io/mregions2/reference/gaz_search_by_source.html This example demonstrates how to list all available sources within the gazetteer. It is useful for identifying source names or IDs for subsequent searches. ```R gaz_sources() ``` -------------------------------- ### Example: Searching Gazetteer records by name Source: https://ropensci.github.io/mregions2/reference/gaz_rest_records_by_names.html Demonstrates how to retrieve Gazetteer records for a vector of specific place names. ```R # \donttest{ gaz_rest_records_by_names( c("Belgian Exclusive Economic Zone", "Dutch Exclusive Economic Zone") ) #> # A tibble: 8 × 14 #> MRGID gazetteerSource placeType latitude longitude minLatitude minLongitude #> #> 1 3293 Flanders Marine I… EEZ 51.5 2.72 51.0 2.24 #> 2 5668 Flanders Marine I… EEZ 53.6 4.19 51.3 2.54 #> 3 26519 Flanders Marine I… EEZ 13.7 -69.7 12.2 -70.4 #> 4 26520 Flanders Marine I… EEZ 12.7 -68.4 11.7 -68.7 #> 5 26517 Flanders Marine I… EEZ 13.2 -69.0 11.7 -69.5 #> 6 26518 Flanders Marine I… EEZ 17.4 -63.6 16.7 -64.0 #> 7 26526 Flanders Marine I… EEZ 17.3 -63.1 16.7 -63.6 #> 8 21803 Flanders Marine I… EEZ 17.9 -63.1 17.8 -63.3 #> # ℹ 7 more variables: maxLatitude , maxLongitude , precision , #> # preferredGazetteerName , preferredGazetteerNameLang , #> # status , accepted # } ``` -------------------------------- ### Install mregions2 from CRAN Source: https://ropensci.github.io/mregions2/index.html Install the latest stable version of the mregions2 package from the Comprehensive R Archive Network (CRAN). ```r install.packages("mregions2") ``` -------------------------------- ### Basic visualization using helper function Source: https://ropensci.github.io/mregions2/reference/mrp_view.html This example demonstrates using a helper function for a specific data product ('eez'). Helper functions simplify the process by pre-selecting the layer. ```R # Or use the helper mrp_view_eez() ``` -------------------------------- ### Get All Place Types Source: https://ropensci.github.io/mregions2/reference/gaz_rest_types.html Retrieves all available place types from the Marine Regions Gazetteer. ```APIDOC ## GET /gazetteer/types ### Description Fetches all available place types from the Marine Regions Gazetteer. ### Method GET ### Endpoint /gazetteer/types ### Parameters None ### Request Example None ### Response #### Success Response (200) - **typeID** (integer) - The identifier of the place type in the Marine Regions Gazetteer database. - **type** (string) - The name of the place type. - **description** (string) - The description of the place type, if available. #### Response Example ```json { "typeID": 1, "type": "Town", "description": "The lowest administrative unit in Belgium and other countries." } ``` ``` -------------------------------- ### Retrieve Gazetteer Records Examples Source: https://ropensci.github.io/mregions2/reference/gaz_search_by_type.html Demonstrates retrieving records for 'EEZ' using both the place type name and the corresponding numeric ID. ```R # \donttest{ # This gaz_search_by_type("EEZ") #> # A tibble: 246 × 14 #> MRGID gazetteerSource placeType latitude longitude minLatitude minLongitude #> #> 1 3293 Flanders Marine … EEZ 51.5 2.72 51.0 2.24 #> 2 5668 Flanders Marine … EEZ 53.6 4.19 51.3 2.54 #> 3 5669 Flanders Marine … EEZ 54.6 8.40 52.9 3.35 #> 4 5670 Flanders Marine … EEZ 40.9 19.1 39.6 18.3 #> 5 5672 Flanders Marine … EEZ 42.9 29.2 42.0 27.4 #> 6 5673 Flanders Marine … EEZ 43.4 15.6 41.6 13.0 #> 7 5674 Flanders Marine … EEZ 56.2 9.21 54.4 3.25 #> 8 5675 Flanders Marine … EEZ 58.8 23.0 57.6 20.4 #> 9 5676 Flanders Marine … EEZ 61.8 21.9 58.8 19.1 #> 10 5677 Flanders Marine … EEZ 46.1 -1.96 41.2 -9.88 #> # ℹ 236 more rows #> # ℹ 7 more variables: maxLatitude , maxLongitude , precision , #> # preferredGazetteerName , preferredGazetteerNameLang , #> # status , accepted # is the same as gaz_search_by_type(70) #> # A tibble: 246 × 14 #> MRGID gazetteerSource placeType latitude longitude minLatitude minLongitude #> #> 1 3293 Flanders Marine … EEZ 51.5 2.72 51.0 2.24 #> 2 5668 Flanders Marine … EEZ 53.6 4.19 51.3 2.54 #> 3 5669 Flanders Marine … EEZ 54.6 8.40 52.9 3.35 #> 4 5670 Flanders Marine … EEZ 40.9 19.1 39.6 18.3 #> 5 5672 Flanders Marine … EEZ 42.9 29.2 42.0 27.4 #> 6 5673 Flanders Marine … EEZ 43.4 15.6 41.6 13.0 #> 7 5674 Flanders Marine … EEZ 56.2 9.21 54.4 3.25 #> 8 5675 Flanders Marine … EEZ 58.8 23.0 57.6 20.4 #> 9 5676 Flanders Marine … EEZ 61.8 21.9 58.8 19.1 #> 10 5677 Flanders Marine … EEZ 46.1 -1.96 41.2 -9.88 #> # ℹ 236 more rows #> # ℹ 7 more variables: maxLatitude , maxLongitude , precision , #> # preferredGazetteerName , preferredGazetteerNameLang , #> # status , accepted # } ``` -------------------------------- ### Example usage of mregions2 data retrieval Source: https://ropensci.github.io/mregions2/reference/mrp_get.html Demonstrates setting the cache path, listing products, inspecting columns, and applying a CQL filter to retrieve specific data. ```R # \donttest{ # Set cache path. Default is a temporal directory options(mregions2.download_path = tempdir()) getOption("mregions2.download_path") #> [1] "/var/folders/bz/h4njq8yd7td8qk42rt_9f0p00000gn/T//Rtmplu0dCb" #> [1] "/tmp/RtmpARLgoE" # See the list of all data products mrp_list #> # A tibble: 21 × 8 #> title namespace layer license citation doi imis abstract #> #> 1 Exclusive Economic Zon… MarineRe… eez Creati… "Flande… http… http… "Versio… #> 2 Maritime Boundaries (v… MarineRe… eez_… Creati… "Flande… http… http… "Versio… #> 3 Territorial Seas (12 N… MarineRe… eez_… Creati… "Flande… http… http… "Versio… #> 4 Contiguous Zones (24 N… MarineRe… eez_… Creati… "Flande… http… http… "Versio… #> 5 Internal Waters (v3, w… MarineRe… eez_… Creati… "Flande… http… http… "Versio… #> 6 Archipelagic Waters (v… MarineRe… eez_… Creati… "Flande… http… http… "Versio… #> 7 High Seas (v1, world, … MarineRe… high… Creati… "Flande… http… http… "High S… #> 8 Extended Continental S… MarineRe… ecs Creati… "Flande… http… http… "This d… #> 9 Extended Continental S… MarineRe… ecs_… Creati… "Flande… http… http… "This d… #> 10 IHO Sea Areas (v3) MarineRe… iho Creati… "Flande… http… http… "World … #> # ℹ 11 more rows # We want the Exclusive Economic Zones of Portugal. Let's first visualize the product: mrp_view("eez") +− Leaflet | EMODnet, Marine Regions # See all the columns on this data product mrp_colnames("eez") #> # A tibble: 31 × 3 #> layer colname type #> * #> 1 eez mrgid int #> 2 eez geoname string #> 3 eez mrgid_ter1 int #> 4 eez pol_type string #> 5 eez mrgid_sov1 int #> 6 eez territory1 string #> 7 eez iso_ter1 string #> 8 eez sovereign1 string #> 9 eez mrgid_ter2 int #> 10 eez mrgid_sov2 int #> # ℹ 21 more rows # We should query on sovereign # See all the possible values of sovereign1, sovereign2 and sovereign3 sov1 = mrp_col_unique("eez", "sovereign1") sov2 = mrp_col_unique("eez", "sovereign2") sov3 = mrp_col_unique("eez", "sovereign3") # Is Portugal a value in the sovereign1, 2 and 3? "Portugal" %in% sov1 #> [1] TRUE #> [1] TRUE "Portugal" %in% sov2 #> [1] FALSE #> [1] FALSE "Portugal" %in% sov3 #> [1] FALSE #> [1] FALSE # Portugal is only in sovereign1. Let's write a CQL filter to get only # the EEZs of Portugal, or those where Portugal is a party of a dispute or a joint regime portugal_eez <- mrp_get("eez", cql_filter = "sovereign1 = 'Portugal'") ``` -------------------------------- ### GET gaz_rest_sources Source: https://ropensci.github.io/mregions2/reference/gaz_rest_sources.html Retrieves a list of all available Marine Regions sources from the Gazetteer database. ```APIDOC ## GET gaz_rest_sources ### Description Retrieves all Marine Regions sources available in the Gazetteer database. This function is also available as `gaz_sources()`. ### Method GET ### Endpoint gaz_rest_sources() ### Response #### Success Response (200) - **sourceID** (integer) - The identifier of the source in the Marine Regions Gazetteer database. - **source** (string) - The name of the source. - **sourceURL** (string) - The URL of the source, if available. #### Response Example { "sourceID": 1, "source": "SAIL", "sourceURL": "http://www.marineregions.org/" } ``` -------------------------------- ### List Available Marine Regions Data Products Source: https://ropensci.github.io/mregions2/index.html Use `mrp_list()` to get an overview of all available data products. This function returns a tibble with details for each product. ```r mrp_list ``` -------------------------------- ### Search Marine Regions Gazetteer Source: https://ropensci.github.io/mregions2/reference/gaz_search.html Examples demonstrating how to search by name, retrieve records by MRGID with geometry, and filter by language. ```R gaz_search(x, ...) # S3 method for class 'character' gaz_search(x, ...) # S3 method for class 'numeric' gaz_search(x, ..., y = NULL) # S3 method for class 'sfg' gaz_search(x, ...) # S3 method for class 'sf' gaz_search(x, ...) # S3 method for class 'sfc' gaz_search(x, ...) ``` ```R # Look-up a name in the Gazetteer gaz_search("North Sea") # Get the entries of two known MRGID including their geometry gaz_search(c(14, 17), with_geometry = TRUE) # Maybe the name is in another language... gaz_search("Noordzee", language = "nl") ``` -------------------------------- ### Marine Regions Gazetteer RESTful Services Documentation Source: https://ropensci.github.io/mregions2/reference/gaz_rest.html This entry provides access to the documentation for the Marine Regions RESTful API. The functions starting with 'gaz_rest_*' in the mregions2 package are wrappers for these services. ```APIDOC ## Marine Regions Gazetteer RESTful Services (Documentation) ### Description REST (REpresentational State Transfer) is a simple stateless architecture that generally runs over HTTP. mregions2 makes use of the RESTful API created and maintained by Marine Regions. The functions with names starting as `gaz_rest_*` perform HTTP requests to read the Marine Regions REST API. They are closer to the definition of each function in the Marine Regions REST API. All the gazetteer functions such as `gaz_search()` or `gaz_relations()` make use of these `gaz_rest_*` functions. ### Value Returns a help page: `gaz_rest` is not a function but documentation. ### See also `gaz_rest_geometries()`, `gaz_rest_names_by_mrgid()`, `gaz_rest_record_by_mrgid()`, `gaz_rest_records_by_lat_long()`, `gaz_rest_records_by_name()`, `gaz_rest_records_by_names()`, `gaz_rest_records_by_source()`, `gaz_rest_records_by_type()`, `gaz_rest_relations_by_mrgid()`, `gaz_rest_sources()`, `gaz_rest_source_by_sourceid()`, `gaz_rest_types()`, `gaz_rest_wmses()` ### Examples ```R ?gaz_rest ``` ``` -------------------------------- ### Initialize Virtuoso Database for RDF Storage Source: https://ropensci.github.io/mregions2/articles/mregions2-rdf.html Demonstrates how to configure a Virtuoso triplestore backend and parse N-Quads data into it using rdflib. ```R triplestore <- rdf(storage = "virtuoso", user = "dba", password = "dba", dsn = "Local Virtuoso" ) # Turn bpns into nquads tmp <- tempfile(fileext = ".nq") write_nquads(bpns, tmp) # Parse bpns as nquads into the store rdf_parse(tmp, format = "nquads", rdf = triplestore) ``` -------------------------------- ### GET /gaz_rest_records_by_source Source: https://ropensci.github.io/mregions2/reference/gaz_rest_records_by_source.html Retrieves a list of Gazetteer records associated with a specific source. ```APIDOC ## GET /gaz_rest_records_by_source ### Description Retrieve Gazetteer records filtered by a specific source name. ### Method GET ### Parameters #### Query Parameters - **source** (character) - Required - A source name from gaz_rest_sources() - **with_geometry** (logical) - Optional - Add geometries to the result data frame? Default = FALSE ### Response #### Success Response (200) - **data** (data.frame) - A data frame containing Gazetteer entries including MRGID, placeType, coordinates, and names. ``` -------------------------------- ### GET gaz_rest_geometries Source: https://ropensci.github.io/mregions2/reference/gaz_rest_geometries.html Retrieves the geometries associated with a specific Marine Regions Gazetteer Identifier (MRGID). ```APIDOC ## GET gaz_rest_geometries ### Description Retrieves the geometries associated with a gazetteer record based on the provided MRGID. ### Method GET ### Parameters #### Arguments - **mrgid** (integer) - Required - A valid Marine Regions Gazetteer Identifier (MRGID). - **format** (character) - Optional - The preferred output format. One of: "sfc" (Simple Feature geometry object), "wkt" (Well-Known Text), or "rdf" (RDF object). Default is "sfc". - **multipart** (logical) - Optional - If TRUE (default), returns multipart geometries (e.g. MULTIPOLYGON). If FALSE, returns singlepart geometries. ### Value A sfc object (default), a sf data frame, a WKT string, or an RDF object. ``` -------------------------------- ### GET /eez_boundaries Source: https://ropensci.github.io/mregions2/articles/mrp_ontology.html Retrieves the list of maritime boundary features from the VLIZ Maritime Boundaries Geodatabase. ```APIDOC ## GET /eez_boundaries ### Description Retrieves the maritime boundary features including sovereign information, territory identifiers, and source documentation. ### Method GET ### Endpoint /eez_boundaries ### Response #### Success Response (200) - **line_id** (decimal) - Unique identifier of feature. - **line_name** (string) - Name of the feature. - **line_type** (string) - Basis of creation or legal status of feature. - **mrgid_sov1** (decimal) - MRGID of the sovereign nation feature. - **mrgid_ter1** (decimal) - MRGID of the territory feature. - **territory1** (string) - Specific land area related to the feature. - **sovereign1** (string) - State that claims jurisdiction. - **mrgid_ter2** (decimal) - MRGID of the second territory feature. - **territory2** (string) - Specific land area related to the feature. - **mrgid_sov2** (decimal) - MRGID of the second sovereign nation feature. - **sovereign2** (string) - State that claims jurisdiction. - **mrgid_eez1** (decimal) - MRGID of the EEZ feature. - **eez1** (string) - Name of the EEZ feature. - **mrgid_eez2** (decimal) - MRGID of the second EEZ feature. - **eez2** (string) - Name of the second EEZ feature. - **source1/2/3** (string) - Authoritative source names. - **url1/2/3** (string) - URLs to authoritative sources. - **origin** (string) - Type of source of feature. - **doc_date** (date) - Date of publication. - **mrgid_jreg** (decimal) - MRGID of the Joint Regime polygon. - **joint_reg** (string) - Name of the Joint Regime polygon. - **length_km** (decimal) - Length of feature in kilometers. ``` -------------------------------- ### GET gaz_geometry Source: https://ropensci.github.io/mregions2/reference/gaz_geometry.html Retrieves the geometry of a Marine Regions Geo-Object based on an MRGID or a data frame. ```APIDOC ## GET gaz_geometry ### Description Retrieves the geometries of a Marine Regions Geo-Object. The function accepts either a numeric MRGID or a data frame retrieved via other mregions2 functions. ### Method GET ### Parameters #### Path Parameters - **x** (numeric/data.frame) - Required - A valid Marine Regions Gazetteer Identifier (MRGID) or a data frame retrieved with mregions2 functions. #### Query Parameters - **format** (character) - Optional - The preferred output format. Options: "sfc" (default), "wkt", or "rdf". - **multipart** (logical) - Optional - If TRUE (default), returns multipart geometries (e.g., MULTIPOLYGON). If FALSE, returns singlepart geometries. ### Response - **Value** (sfc/sf/character/rdf) - Returns an sfc object, sf data frame, WKT string, or RDF object depending on the requested format. ``` -------------------------------- ### Filter data using client-side vs server-side methods Source: https://ropensci.github.io/mregions2/articles/mregions2.html Compares filtering the full dataset locally versus applying a CQL filter on the server to improve performance. ```R ecs <- mrp_get("ecs") %>% filter(sovereign1 == "Portugal") ``` ```R ecs <- mrp_get("ecs", cql_filter = "sovereign1 = 'Portugal'") ``` -------------------------------- ### GET /gaz_rest_record_by_mrgid Source: https://ropensci.github.io/mregions2/reference/gaz_rest_record_by_mrgid.html Retrieves a single record from the Marine Regions Gazetteer based on a provided MRGID. ```APIDOC ## GET /gaz_rest_record_by_mrgid ### Description Retrieves a single record from the Marine Regions Gazetteer using a unique Marine Regions Gazetteer Identifier (MRGID). ### Parameters #### Query Parameters - **mrgid** (integer) - Required - A valid Marine Regions Gazetteer Identifier (MRGID). - **with_geometry** (logical) - Optional - Add geometry to the result data frame. Default = FALSE. - **rdf** (logical) - Optional - Return an object of class rdflib::rdf. Default = FALSE. ### Response #### Success Response (200) - **data** (data.frame) - A data frame containing the Gazetteer entry details. ``` -------------------------------- ### Access MRGID Documentation - R Source: https://ropensci.github.io/mregions2/reference/MRGID.html Use this command to display the help page for MRGID within the mregions2 R package. This is not a function call but a way to access documentation. ```r ?MRGID ``` -------------------------------- ### GET gaz_rest_records_by_lat_long Source: https://ropensci.github.io/mregions2/reference/gaz_rest_records_by_lat_long.html Retrieves all gazetteer records where the geometry intersects with the provided latitude and longitude coordinates. ```APIDOC ## GET gaz_rest_records_by_lat_long ### Description Retrieves all gazetteer records where the geometry intersects with the given latitude and longitude. Coordinates are assumed to be in WGS84. ### Parameters #### Query Parameters - **latitude** (double) - Required - A decimal number ranging from -90 to 90. - **longitude** (double) - Required - A decimal number ranging from -180 to 180. - **with_geometry** (logical) - Optional - Add geometries to the result data frame. Default = FALSE. - **typeid** (numeric) - Optional - Restrict to one or more placetypeIDs. ### Request Example ```r gaz_rest_records_by_lat_long(51.21551, 2.927, with_geometry = TRUE, typeid = c(255, 259)) ``` ### Response #### Success Response (200) - **data frame** (object) - A data frame containing Gazetteer entries, optionally including geometry columns. ``` -------------------------------- ### Download Marine Regions Data Products to a Specific Path Source: https://ropensci.github.io/mregions2/index.html Specify a download path using the `path` argument in `mrp_get()`. For example, `mrp_get("eez", path = "path/to/data")` saves the data to the specified directory. ```r mrp_get("eez", path = "path/to/data") ``` -------------------------------- ### GET /gaz_rest_names_by_mrgid Source: https://ropensci.github.io/mregions2/reference/gaz_rest_names_by_mrgid.html Retrieves all names associated with a specific Marine Regions Gazetteer Identifier (MRGID). ```APIDOC ## GET /gaz_rest_names_by_mrgid ### Description Retrieves a vector of all names associated with a given Marine Regions Gazetteer Identifier (MRGID). ### Method GET ### Endpoint gaz_rest_names_by_mrgid(mrgid) ### Parameters #### Path Parameters - **mrgid** (integer) - Required - A valid Marine Regions Gazetteer Identifier (MRGID) ### Response - **vector** (string) - A vector containing all names of the Marine Regions Gazetteer entry. ``` -------------------------------- ### Download Marine Regions Data Products Source: https://ropensci.github.io/mregions2/index.html Use `mrp_get()` to download data products into R. Specify the product name, e.g., `mrp_get("eez")` to download the Exclusive Economic Zones data. ```r mrp_get("eez") ``` -------------------------------- ### GET gaz_rest_wmses Source: https://ropensci.github.io/mregions2/reference/gaz_rest_wmses.html Retrieves WMS service information for a given Marine Regions Gazetteer Identifier (MRGID). ```APIDOC ## GET gaz_rest_wmses ### Description Retrieves WMS service information for a given Marine Regions Gazetteer Identifier (MRGID). ### Method GET ### Parameters #### Path Parameters - **mrgid** (integer) - Required - A valid Marine Regions Gazetteer Identifier (MRGID) ### Response #### Success Response (200) - **value** (string) - The value to filter on - **MRGID** (integer) - The MRGID identifier - **url** (string) - The base URL of the WMS service - **namespace** (string) - The namespace of the service - **featureType** (string) - The feature type - **featureName** (string) - The feature name ### Request Example gaz_rest_wmses(3293) ### Response Example # A tibble: 1 × 6 # value MRGID url namespace featureType featureName # # 1 3293 3293 https://geo.vliz.be/geoserver/w… MarineRe… eez mrgid ``` -------------------------------- ### GET /gaz_rest_source_by_sourceid Source: https://ropensci.github.io/mregions2/reference/gaz_rest_source_by_sourceid.html Retrieves the name and URL of a source from the Marine Regions database by providing its unique sourceID. ```APIDOC ## GET gaz_rest_source_by_sourceid ### Description Get the name of a source by providing a sourceID. ### Method GET ### Parameters #### Arguments - **sourceid** (integer) - Required - A valid sourceID ### Response - **Value** (named vector) - A named vector containing the source name and, if available, the URL to the source. ### Request Example ```r gaz_rest_source_by_sourceid(390) ``` ### Response Example ```json { "source": "Flanders Marine Institute (2018). Maritime Boundaries Geodatabase...", "url": "http://www.marineregions.org" } ``` ``` -------------------------------- ### Filter 'ecoregions' data using CQL filter Source: https://ropensci.github.io/mregions2/reference/mrp_view.html This example filters the 'ecoregions' data product using a more concise CQL filter. CQL filters are generally preferred for their brevity compared to OGC filters. ```R # OGC filter are very verbose... but luckily you can use a CQL filter instead mrp_view_ecoregions(cql_filter = "ecoregion = 'Azores Canaries Madeira'") ``` -------------------------------- ### List All Sources Source: https://ropensci.github.io/mregions2/articles/mregions2.html Retrieves a list of all available data sources for marine regions. ```APIDOC ## List sources gaz_sources() ### Description Retrieves a tibble containing all available data sources for marine regions. ### Method GET ### Endpoint /gazetteer/sources ### Parameters None ### Request Example ```r gaz_sources() ``` ### Response #### Success Response (200) - **sourceID** (int) - Unique identifier for the source. - **source** (chr) - Name of the data source. - **sourceURL** (chr) - URL associated with the data source (if available). #### Response Example ```json [ { "sourceID": 1, "source": "SAIL", "sourceURL": "http://w..." }, { "sourceID": 2, "source": "ASFA thesaurus", "sourceURL": "http://w..." } ] ``` ``` -------------------------------- ### Serialize RDF to JSON-LD Source: https://ropensci.github.io/mregions2/articles/mregions2-rdf.html Prepare a file path for serializing an RDF object into JSON-LD format. ```R # Create a placeholder file bpns_as_jsonld <- tempfile(fileext = ".rdf") ``` -------------------------------- ### Inspect data product schema and values Source: https://ropensci.github.io/mregions2/articles/mregions2.html Retrieves column metadata and unique values to assist in constructing valid CQL filters. ```R # Columns of the Extended Continental Shelves data product mrp_colnames("ecs") ``` ```R # Unique values of the column pol_type mrp_col_unique("ecs", "pol_type") ``` -------------------------------- ### GET gaz_rest_records_by_names Source: https://ropensci.github.io/mregions2/reference/gaz_rest_records_by_names.html Retrieves Gazetteer records for a provided vector of names, with options for fuzzy matching and geometry inclusion. ```APIDOC ## GET gaz_rest_records_by_names ### Description Retrieves Gazetteer records for all given names from the Marine Regions Gazetteer. ### Parameters #### Query Parameters - **names** (character) - Required - Vector with the terms to search in the Marine Regions Gazetteer. - **with_geometry** (logical) - Optional - Add geometry to the result data frame? Default = FALSE. - **like** (logical) - Optional - Add a '%'-sign before and after the name (SQL LIKE function). Default = TRUE. - **fuzzy** (logical) - Optional - Use Levenshtein query to find nearest matches. Default = TRUE. ### Response #### Success Response (200) - **data frame** - A data frame containing Gazetteer entries including MRGID, placeType, coordinates, and status. ``` -------------------------------- ### Retrieve Gazetteer Record as RDF Source: https://ropensci.github.io/mregions2/articles/mregions2-rdf.html Fetch a gazetteer record in RDF format using content negotiation via the rdf = TRUE argument. ```R bpns <- gaz_search(3293, rdf = TRUE) class(bpns) #> [1] "rdf" bpns #> Total of 99 triples, stored in hashes #> ------------------------------- #> @base . #> @prefix rdf: . #> #> #> a , ; #> "Belgium"@en . #> #> #> a , ; #> "Birkenfels"@en . #> #> ... with 89 more triples ``` -------------------------------- ### GET gaz_search_by_type Source: https://ropensci.github.io/mregions2/reference/gaz_search_by_type.html Retrieves a list of Gazetteer records filtered by a specific place type, identified by either name or ID. ```APIDOC ## GET gaz_search_by_type ### Description Retrieve Gazetteer records from Marine Regions based on a provided place type. The function supports searching by either the name of the place type (character) or the type ID (integer). ### Method GET ### Parameters #### Path Parameters - **x** (character/integer) - Required - The place type name or the typeid of a place type. #### Query Parameters - **with_geometry** (logical) - Optional - Add geometries to the result data frame? Default = FALSE. ### Response #### Success Response (200) - **data.frame** - A tibble containing Gazetteer entries including MRGID, gazetteerSource, placeType, latitude, longitude, and other spatial metadata. ### Request Example ```r # Search by name gaz_search_by_type("EEZ") # Search by ID gaz_search_by_type(70) ``` ``` -------------------------------- ### Filter EEZ boundaries by date range using timestamp format Source: https://ropensci.github.io/mregions2/reference/mrp_view.html This example filters the 'eez_boundaries' data product using a CQL filter with dates specified in a timestamp format. This demonstrates an alternative way to specify date ranges. ```R # Or as timestamp mrp_view_eez_boundaries( cql_filter = "doc_date AFTER 2000-01-01T00:00:00Z AND doc_date BEFORE 2009-12-31T00:00:00Z" ) ``` -------------------------------- ### Get All Marine Regions Sources Source: https://ropensci.github.io/mregions2/reference/gaz_sources.html Retrieves a data frame containing all available sources from the Marine Regions Gazetteer database. ```APIDOC ## GET /gaz/sources ### Description Retrieves a data frame with information about all Marine Regions sources. ### Method GET ### Endpoint /gaz/sources ### Parameters None ### Request Example None ### Response #### Success Response (200) - **sourceID** (integer) - The identifier of the source in the Marine Regions Gazetteer database. - **source** (string) - The name of the source. - **sourceURL** (string) - If available, the URL of the source. #### Response Example ```json { "sources": [ { "sourceID": 1, "source": "SAIL", "sourceURL": "http://www.sail.org" }, { "sourceID": 2, "source": "ASFA thesaurus", "sourceURL": "http://www.fao.org/fi/asfa" } ] } ``` ``` -------------------------------- ### Configure download path for mrp_get Source: https://ropensci.github.io/mregions2/articles/mregions2.html Overrides the default temporary directory for caching downloaded files. ```R ecs <- mrp_get("ecs", path = "path/to/data") ``` ```R options("mregions2.download_path" = "path/to/data") ecs <- mrp_get("ecs") ``` -------------------------------- ### Get Marine Regions Sources Source: https://ropensci.github.io/mregions2/reference/gaz_rest_sources.html Retrieves a data frame containing all available Marine Regions sources. This function is memoised. ```R gaz_rest_sources() ``` ```R # This gaz_rest_sources() #> # A tibble: 704 × 3 #> sourceID source sourceURL #> #> 1 1 SAIL http://w… #> 2 2 ASFA thesaurus http://w… #> 3 4 Nationaal Instituut voor de Statistiek (NIS) / National S… http://s… #> 4 5 Oosthoek Times Wereldatlas NA #> 5 6 Lausch, E. (2000). Atlas van de oceanen: met de dieptekaa… NA #> 6 7 (2001). The Times comprehensive atlas of the world. 10th … NA #> 7 8 IHO-IOC GEBCO Gazetteer of Undersea Feature Names (2002-1… http://w… #> 8 9 BIOMARE http://w… #> 9 10 (1953). Limits of oceans and seas. 3rd edition. IHO Speci… NA #> 10 11 Nomenclature des espaces maritimes/List of maritime areas NA #> # ℹ 694 more rows # is the same as gaz_sources() #> # A tibble: 704 × 3 #> sourceID source sourceURL #> #> 1 1 SAIL http://w… #> 2 2 ASFA thesaurus http://w… #> 3 4 Nationaal Instituut voor de Statistiek (NIS) / National S… http://s… #> 4 5 Oosthoek Times Wereldatlas NA #> 5 6 Lausch, E. (2000). Atlas van de oceanen: met de dieptekaa… NA #> 6 7 (2001). The Times comprehensive atlas of the world. 10th … NA #> 7 8 IHO-IOC GEBCO Gazetteer of Undersea Feature Names (2002-1… http://w… #> 8 9 BIOMARE http://w… #> 9 10 (1953). Limits of oceans and seas. 3rd edition. IHO Speci… NA #> 10 11 Nomenclature des espaces maritimes/List of maritime areas NA #> # ℹ 694 more rows ``` -------------------------------- ### Load mregions2 and helper libraries Source: https://ropensci.github.io/mregions2/articles/mregions2.html Load the mregions2 package and other commonly used libraries for data manipulation and spatial analysis. The pipe operator `%>%` from magrittr is also loaded for illustrative purposes. ```R library(mregions2) # To use the pipe operator `%>% library(magrittr) # For illustrative purposes library(sf) library(dplyr) ```