Skip to content

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.

License

Notifications You must be signed in to change notification settings

pepijn-devries/CopernicusMarine

Repository files navigation

CopernicusMarine Easily access information from https://data.marine.copernicus.eu

R-CMD-check cranlogs version cran checks ggsankeyfier status badge

Overview

CopernicusMarine logo

Copernicus Marine Service Information 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 https://data.marine.copernicus.eu. 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. 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.

Installation

Get CRAN version

install.packages("CopernicusMarine")

Get development version on github

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. The usage section briefly shows three different ways of obtaining data from Copernicus:

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. It seems that it might take some time to get this fixed. In the meantime, you could have a look at this work-around.

Downloading a complete Copernicus marine product

If you don’t want to subset the data and want the complete set, you can use the SpatioTemporal Asset Catalogs (STAC), if these are available for your product. First you can list STAC files available for a specific product (and layer):

stac_files <-
  cms_list_stac_files(
    "GLOBAL_ANALYSISFORECAST_PHY_001_024",
    "cmems_mod_glo_phy-cur_anfc_0.083deg_P1D-m")
stac_files
#> # A tibble: 915 × 8
#>    home          native current_path LastModified ETag  Size  StorageClass Type 
#>    <chr>         <chr>  <chr>        <chr>        <chr> <chr> <chr>        <chr>
#>  1 s3.waw3-1.cl… mdl-n… native/GLOB… 2024-04-18T… "\"4… 1939… STANDARD     Norm…
#>  2 s3.waw3-1.cl… mdl-n… native/GLOB… 2024-04-18T… "\"9… 1939… STANDARD     Norm…
#>  3 s3.waw3-1.cl… mdl-n… native/GLOB… 2024-04-18T… "\"9… 1939… STANDARD     Norm…
#>  4 s3.waw3-1.cl… mdl-n… native/GLOB… 2024-04-18T… "\"c… 1939… STANDARD     Norm…
#>  5 s3.waw3-1.cl… mdl-n… native/GLOB… 2024-04-18T… "\"2… 1938… STANDARD     Norm…
#>  6 s3.waw3-1.cl… mdl-n… native/GLOB… 2024-04-18T… "\"0… 1938… STANDARD     Norm…
#>  7 s3.waw3-1.cl… mdl-n… native/GLOB… 2024-04-18T… "\"5… 1939… STANDARD     Norm…
#>  8 s3.waw3-1.cl… mdl-n… native/GLOB… 2024-04-18T… "\"5… 1939… STANDARD     Norm…
#>  9 s3.waw3-1.cl… mdl-n… native/GLOB… 2024-04-18T… "\"9… 1939… STANDARD     Norm…
#> 10 s3.waw3-1.cl… mdl-n… native/GLOB… 2024-04-18T… "\"1… 1939… STANDARD     Norm…
#> # ℹ 905 more rows

Downloading the first file can be done with cms_download_stac(stac_files[1,,drop = FALSE], tempdir()), where the file would be stored in a temporary directory. 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 widgets. This is demonstrated with the example below (note that in the documentation the map is only shown statically and is not interactive).

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 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:

cms_cite_product("GLOBAL_ANALYSISFORECAST_PHY_001_024")
#>                                                                                                                                                                 doi 
#> "E.U. Copernicus Marine Service Information; Global Ocean Physics Analysis and Forecast - GLOBAL_ANALYSISFORECAST_PHY_001_024 (2016-10-14). DOI:10.48670/moi-00016"

Resources

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages