Skip to content

Commit

Permalink
feat: mrp_ontology df defining each attr (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
salvafern committed Sep 15, 2023
1 parent dcbd99e commit ca09f8a
Show file tree
Hide file tree
Showing 12 changed files with 578 additions and 17 deletions.
19 changes: 19 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,22 @@
#' @examples
#' mrp_list
"mrp_list"

#' Marine Regions Data Products Ontology
#'
#' More information available at `vignette("mrp_ontology", package = "mregions2")`
#'
#' @format ## `mrp_ontology`
#' A data frame with 374 rows and 4 columns:
#' \describe{
#' \item{layer}{Identifier of the data product. Use in [mrp_get()]}
#' \item{colname}{Name of the columns of each data product.}
#' \item{type}{Data type of the column.}
#' \item{definition}{Definition of the column.}
#' }
#'
#' @source <https://marineregions.org/sources.php> <https://marineregions.org/eezattribute.php>
#'
#' @examples
#' mrp_ontology
"mrp_ontology"
8 changes: 8 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
output: github_document
df_print: tibble
---

```{r, include = FALSE}
Expand Down Expand Up @@ -30,6 +31,7 @@ You can find detailed information in the articles online:

- [Introduction to mregions2](https://lifewatch.github.io/mregions2/articles/mregions2.html)
- [Why mregions and mregions2?](https://lifewatch.github.io/mregions2/articles/why_mregions2.html)
- [Marine Regions Data Products Ontology](https://lifewatch.github.io/mregions2/articles/mrp_ontology.html)
- [mregions2 as RDF](https://lifewatch.github.io/mregions2/articles/mregions2-rdf.html)

## Installation
Expand Down Expand Up @@ -132,6 +134,12 @@ An overview of all available products can be consulted with `mrp_list`
mrp_list
```

Their attributes are explained in the [Marine Regions Data Products Ontology article](https://lifewatch.github.io/mregions2/articles/mrp_ontology.html), or simply run `mrp_ontology`

```{r prod_ontology}
mrp_ontology
```

You can visualize the Marine Regions Data Products with `mrp_view()`. It opens an interactive `leaflet::leaflet` viewer.

```{r prod1, eval=FALSE}
Expand Down
52 changes: 39 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ You can find detailed information in the articles online:
mregions2](https://lifewatch.github.io/mregions2/articles/mregions2.html)
- [Why mregions and
mregions2?](https://lifewatch.github.io/mregions2/articles/why_mregions2.html)
- [Marine Regions Data Products
Ontology](https://lifewatch.github.io/mregions2/articles/mrp_ontology.html)
- [mregions2 as
RDF](https://lifewatch.github.io/mregions2/articles/mregions2-rdf.html)

Expand Down Expand Up @@ -189,10 +191,9 @@ gaz_search(3293) %>% gaz_geometry()
#> MRGID gazetteerSource placeType latitude longitude minLatitude minLongitude
#> <int> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 3293 Flanders Marine I… EEZ 51.5 2.71 51.1 2.24
#> # … with 8 more variables: maxLatitude <dbl>, maxLongitude <dbl>,
#> # precision <dbl>, preferredGazetteerName <chr>,
#> # preferredGazetteerNameLang <chr>, status <chr>, accepted <int>,
#> # the_geom <MULTIPOLYGON [°]>
#> # ℹ 8 more variables: maxLatitude <dbl>, maxLongitude <dbl>, precision <dbl>,
#> # preferredGazetteerName <chr>, preferredGazetteerNameLang <chr>,
#> # status <chr>, accepted <int>, the_geom <MULTIPOLYGON [°]>

# Or get only the geometry
gaz_geometry(3293, format = "sfc")
Expand All @@ -211,7 +212,7 @@ hierarchically. You can browse this hierarchy up and down with
``` r
# Get all relations
gaz_search(3293) %>% gaz_relations()
#> # A tibble: 31 × 14
#> # A tibble: 36 × 14
#> MRGID gazetteerSource placeType latitude longitude minLatitude minLongitude
#> <int> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 3293 Flanders Marine … EEZ 51.5 2.71 51.1 2.24
Expand All @@ -224,13 +225,14 @@ gaz_search(3293) %>% gaz_relations()
#> 8 2550 ASFA thesaurus Coast 51.2 2.91 51.1 2.54
#> 9 17401 Aphia Wreck 51.4 2.32 NA NA
#> 10 17409 Aphia Wreck 51.1 2.33 NA NA
#> # … with 21 more rows, and 7 more variables: maxLatitude <dbl>,
#> # maxLongitude <dbl>, precision <dbl>, preferredGazetteerName <chr>,
#> # preferredGazetteerNameLang <chr>, status <chr>, accepted <int>
#> # ℹ 26 more rows
#> # ℹ 7 more variables: maxLatitude <dbl>, maxLongitude <dbl>, precision <dbl>,
#> # preferredGazetteerName <chr>, preferredGazetteerNameLang <chr>,
#> # status <chr>, accepted <int>

# Or get the relations directly
gaz_relations(3293)
#> # A tibble: 31 × 14
#> # A tibble: 36 × 14
#> MRGID gazetteerSource placeType latitude longitude minLatitude minLongitude
#> <int> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 3293 Flanders Marine … EEZ 51.5 2.71 51.1 2.24
Expand All @@ -243,9 +245,10 @@ gaz_relations(3293)
#> 8 2550 ASFA thesaurus Coast 51.2 2.91 51.1 2.54
#> 9 17401 Aphia Wreck 51.4 2.32 NA NA
#> 10 17409 Aphia Wreck 51.1 2.33 NA NA
#> # … with 21 more rows, and 7 more variables: maxLatitude <dbl>,
#> # maxLongitude <dbl>, precision <dbl>, preferredGazetteerName <chr>,
#> # preferredGazetteerNameLang <chr>, status <chr>, accepted <int>
#> # ℹ 26 more rows
#> # ℹ 7 more variables: maxLatitude <dbl>, maxLongitude <dbl>, precision <dbl>,
#> # preferredGazetteerName <chr>, preferredGazetteerNameLang <chr>,
#> # status <chr>, accepted <int>
```

## Marine Regions Data Products
Expand All @@ -272,7 +275,30 @@ mrp_list
#> 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 …
#> # … with 11 more rows
#> # ℹ 11 more rows
```

Their attributes are explained in the [Marine Regions Data Products
Ontology
article](https://lifewatch.github.io/mregions2/articles/mrp_ontology.html),
or simply run `mrp_ontology`

``` r
mrp_ontology
#> # A tibble: 374 × 4
#> layer colname type definition
#> <chr> <chr> <chr> <chr>
#> 1 eez mrgid int Marine Regions Geographic Identifier of the feature.…
#> 2 eez geoname string Name of the feature.
#> 3 eez mrgid_ter1 int Marine Regions Geographic Identifier of the territor…
#> 4 eez pol_type string Basis of creation or legal status of feature. One of…
#> 5 eez mrgid_sov1 int Marine Regions Geographic Identifier of the sovereig…
#> 6 eez territory1 string Specific land area which directly relates to the fea…
#> 7 eez iso_ter1 string ISO 3 code of the territory feature.
#> 8 eez sovereign1 string State that claims jurisdiction over the territory.
#> 9 eez mrgid_ter2 int Marine Regions Geographic Identifier of the territor…
#> 10 eez mrgid_sov2 int Marine Regions Geographic Identifier of the sovereig…
#> # ℹ 364 more rows
```

You can visualize the Marine Regions Data Products with `mrp_view()`. It
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ reference:
List, visualize and download the Marine Regions Data Products, such as the Maritime Boundaries
contents:
- mrp_list
- mrp_ontology
- mrp_view
- mrp_get
- mrp_colnames
Expand Down
37 changes: 37 additions & 0 deletions data-raw/mrp_ontology.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## code to prepare `mrp_ontology` df
## DO NOT RUN
## only for reproducibility purposes: edit file at inst/mrp_ontology.csv by hand
#
# library(mregions2)
#
# # Define data frame and get all attributes
# df = data.frame(layer = NULL, column = NULL, type = NULL)
#
# for(layer in mrp_list$layer){
# c = mrp_colnames(layer)
# df <- rbind(df, c)
# }
#
# # Add order flag
# df$n <- 1:nrow(df)
#
# # Inspect
# View(df)
#
# write.csv2(df, "inst/mrp_ontology.csv", row.names = FALSE,
# fileEncoding = "UTF-8", quote = FALSE)

path <- system.file("mrp_ontology.csv", package = "mregions2")
mrp_ontology <- read.csv2(path)

# Drop order flag - internal use only
mrp_ontology$n <- NULL

# Turn into tibble
attr(mrp_ontology, "class") <- c("tbl_df", "tbl", "data.frame")

usethis::use_data(mrp_ontology, overwrite = TRUE, ascii = TRUE)




Binary file added data/mrp_ontology.rda
Binary file not shown.
Loading

0 comments on commit ca09f8a

Please sign in to comment.