An open API service indexing awesome lists of open source software.

https://github.com/pepijn-devries/CopernicusMarine

Subset and download marine data from EU Copernicus Marine Service Information. Import data on the oceans physical and biogeochemical state from Copernicus into R without the need of external software.
https://github.com/pepijn-devries/CopernicusMarine

data spatial

Last synced: 11 months ago
JSON representation

Subset and download marine data from EU Copernicus Marine Service Information. Import data on the oceans physical and biogeochemical state from Copernicus into R without the need of external software.

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
library(CopernicusMarine)
```

# CopernicusMarine logo

[![R-CMD-check](https://github.com/pepijn-devries/CopernicusMarine/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/pepijn-devries/CopernicusMarine/actions/workflows/R-CMD-check.yaml)
![cranlogs](https://cranlogs.r-pkg.org/badges/CopernicusMarine)
[![version](https://www.r-pkg.org/badges/version/CopernicusMarine)](https://CRAN.R-project.org/package=CopernicusMarine)
[![cran checks](https://badges.cranchecks.info/worst/CopernicusMarine.svg)](https://cran.r-project.org/web/checks/check_results_CopernicusMarine.html)
[![CopernicusMarine status badge](https://pepijn-devries.r-universe.dev/badges/CopernicusMarine)](https://pepijn-devries.r-universe.dev/CopernicusMarine)

## Overview

[Copernicus Marine Service Information](https://marine.copernicus.eu/about) is a programme subsidised by the
European Commission. Its mission is to provide free authoritative information on the oceans physical and
biogeochemical state. The `CopernicusMarine` R package is developed apart from this programme and facilitates
retrieval of information from . With the package you can:

* List available marine data for Copernicus and provide meta-information.
* Download and use the data directly in R.

## Why use `CopernicusMarine`

Copernicus Marine offers access to their data services through a
[Python application interface](https://pypi.org/project/copernicusmarine/).
For R users this requires complex installation procedures and is difficult to maintain in
a stable R package. The `CopernicusMarine` R package has
a much simpler installation procedure (see below) and does not depend on
third party software, other than packages available from [CRAN](https://cran.r-project.org/).

## Installation

> Get CRAN version
```{r eval=FALSE}
install.packages("CopernicusMarine")
```
> Get development version on github
```{r eval=FALSE}
devtools::install_github('pepijn-devries/CopernicusMarine')
```

## Usage

The package provides an interface between R and the Copernicus Marine services. Note that for some of these
services you need an account and have to comply with
[specific terms](https://marine.copernicus.eu/user-corner/service-commitments-and-licence). The usage section
briefly shows three different ways of obtaining data from Copernicus:

* [Downloading a subset](#sec-subset)
* [Downloading a full dataset](#sec-full)
* [Using the WMTS server](#sec-wtms)

Please check the manual for complete documentation of the package.

Downloading a subset

Unfortunately, downloading subsets is not operational in R due to some
[technical issues](https://github.com/pepijn-devries/CopernicusMarine/issues/42).
It seems that it might take some time to get this fixed. In the meantime,
you could have a look at this
[work-around](https://github.com/pepijn-devries/CopernicusMarine/issues/42#issuecomment-2079745370).

Downloading a complete Copernicus marine product

If you don't want to subset the data and want the complete set, you can download
complete native files, if these are available for your product.
You can list available files with:

```{r, eval=TRUE}
native_files <-
cms_list_native_files(
"GLOBAL_ANALYSISFORECAST_PHY_001_024",
"cmems_mod_glo_phy-cur_anfc_0.083deg_P1D-m")
native_files
```

Downloading the first file can be done with:
```{r, eval=FALSE}
cms_download_native(
destination = tempdir(),
product = "GLOBAL_ANALYSISFORECAST_PHY_001_024",
layer = "cmems_mod_glo_phy_anfc_0.083deg_PT1H-m",
pattern = "m_20220630"
)
```
The file would be stored in the specified destination folder.
By default the progress is printed as files can be very large and may take some time to download.

Copernicus Web Map Tile Services (WMTS)

Web Map Tile Services (WMTS) allow to quickly plot pre-rendered images onto a map. This may not be useful when
you need the data for analyses but is handy for quick visualisations, inspection or presentation of data.
In R it is very easy to add WMTS layers to an interactive map using [leaflet](https://rstudio.github.io/leaflet/)
statically and is not interactive).

```{r leaflet, eval=TRUE, message=FALSE, warning=FALSE}
leaflet::leaflet() |>
leaflet::setView(lng = 3, lat = 54, zoom = 4) |>
leaflet::addProviderTiles("Esri.WorldImagery") |>
addCmsWMTSTiles(
product = "GLOBAL_ANALYSISFORECAST_PHY_001_024",
layer = "cmems_mod_glo_phy-thetao_anfc_0.083deg_P1D-m",
variable = "thetao"
)
```

### Citing the data you use

A Copernicus account comes with several terms of use. One of these is that you
[properly cite](https://help.marine.copernicus.eu/en/articles/4444611-how-to-cite-copernicus-marine-products-and-services)
the data you use in publications. In fact, we also have credit the data used in this documentation, which can be easily
done with the following code:

```{r, eval=TRUE}
cms_cite_product("GLOBAL_ANALYSISFORECAST_PHY_001_024")$doi
```

## Resources

```{r, eval=TRUE, echo=FALSE}
cop_det <- cms_product_details("GLOBAL_ANALYSISFORECAST_PHY_001_024")
```

* [E.U. Copernicus Marine Service Information](https://data.marine.copernicus.eu)
* `r sprintf("[%s - %s (%s); DOI:%s](https://doi.org/%s)", cop_det$title, cop_det$id, cop_det$properties$creationDate, cop_det[["sci:doi"]], cop_det[["sci:doi"]])`