Published May 8, 2026 | Version 0.0.6
Dataset Open

DIASPARA - Habitat database

  • 1. ROR icon Institut National de Recherche pour l'Agriculture, l'Alimentation et l'Environnement
  • 2. DIASPARA
  • 3. ROR icon Natural Resources Institute Finland

Contributors

Data manager:

Project leader:

  • 1. Institut National de Recherche pour l'Agriculture l'Alimentation et l'Environnement Nouvelle-Aquitaine Bordeaux Centre

Description

Continental and marine habitat for diadromous Fishes in Europe, United States and Canadian East coast. These files contain the referentials for river, lakes and catchments from hydrosheds, plus referentials based on hydroshed and ICES and GFCM referentials in the marine area to describe a hierarchy of habitats, for ICES diadromous fish working groups WGNAS, WGBAST and WGEEL. The main product is table ref.tr_area_area which contains the code for all working groups. It can be downloaded as excel, shapefile, parquet file (in refnas, refbast, refeel.zip) or best postgres file. The table contains two geometry columns as the reference area can be a stock unit, or country, or EMU (eel management unit), or basin and in this case it is a polygon (column geom_polygon), but it can correpond to a river segment, and in that case it's a line (column geom_line). For that reason, parquet file is incomplete (no rivers) and we have downloaded two shapefile, ref_tr_area_are_geom_polyon_shp.zip exports the polygons, ref_tr_area_are_geom_line_shp.zip it export the line. Otherwise the two tables are identicaL. Finally the content of the file without geometry can be downloaded as an excel file ref.tr_area_are.xlsx .

Please have a look in our report to understand what we have done.

Versions

Version 0.0.6 (May 2026)(THIS RELEASE)

  • Added a file, amended the R code for parquet.

Version 0.0.5 (March 2026) 

  • Added shapefile with both polygon and lines
  • Added excel table of ref.tr_area_area the common vocab for the three working groups

Version 0.0.4 (March 2026) 

  • Added excel file with named rivers (WGNAS, WGBAST)

Version 0.0.3 (March 2026)

  • fixed issue of corrupted format when trying to restore files (for gpc files) tested on server postgres 17.0

Version 0.0.2 (January 2026)

  •   fixed geometry format in parquet for lakes

Version 0.0.1 (December 2025)

  • Eventual structural modifications depending on feedback from WGNAS and WGBAST
  • Adding referential table for WGEEL

Version 0.0.1-beta (July 2025)

  • Beta release for view and test by DIASPARA and WORKING GROUPS.
  • Integration with migdb vocabulary.
  • Starting the integration of specific tables.
  • Adding names to rivers corresponding to ICES vocabularies

Version 0.0.1-pre-beta (mid June 2025)

  • Adding referential tables for hierarchical structure
  • Structure for WGBAST and WGNAS

Version 0.0.1-alpha (mid February 2025)

Download postgres database

If you don't have postgres, download it, make sure to use the stackbuilder program to download postgis. open a shell with command CMD Move to the place where you have downloaded the file using the following command

cd c:/path/to/my/folder

Note psql must be accessible, in windows you can add the path to the postgres bin folder, otherwise you need to add the full path to the postgres bin folder see link to instructions below below we assume that the user you are using to postgres

createdb -U postgres diaspara psql -U postgres diaspara

This will open a command with # where you can launch the following SQL command

CREATE EXTENSION postgis;

You will need this because we only restore part of the database : the schema corresponding to different locations.You will probably want to create roles, if not it's not a problem you'll get some warnings that grants were not created for this user

CREATE ROLE diaspara_admin;
CREATE ROLE diaspara_read;

You need to have these schema ready to restore the content of some tables

CREATE SCHEMA ref;
CREATE SCHEMA refeel;
CREATE SCHEMA refnas;
CREATE SCHEMA refbast;

Now you will have saved the files in the c:/path/to/my/folder location where you are currently working.

You need to use pg_restore to restore the files

If you want to restore everything in one go use :

pg_restore -U postgres -f all_habitat.pgc

This will restore all schemas for different ICES areas plus the habitat tables in schema ref, refbast, refnas and refeel

If you are just interested in a limited set of areas :

The first file to restore is habitat. This is necessary as all tables inherit from habitat.

pg_restore -U postgres -f habitat.pgc

Then if for instance if you want to use h_med_central.pgc use :

pg_restore -U postgres -f h_med_central.pgc

all_ref.gpc contains the code for schema ref, refnas, refeel, refbast (habitats for the three working groups) :

Download Parquet format 

You can use the files straight from R or Qgis. To use with R you will need Arrow and DuckDB packages.

Tutorials

If you need any help to use those, please see the webinar videos and presentation documents that can be found here.

Project page

https://diaspara.bordeaux-aquitaine.inrae.fr

Specific work done by WP3 can be found here.

Description and details about the creation of the Habitat Database can be found here.

Acknowlegment

hydrosheds :

Linke, S., Lehner, B., Ouellet Dallaire, C., Ariwi, J., Grill, G., Anand, M., Beames, P., Burchard-Levine, V., Maxwell, S., Moidu, H., Tan, F., Thieme, M. (2019). Global hydro-environmental sub-basin and river reach characteristics at high spatial resolution. Scientific Data 6: 283. doi: https://doi.org/10.1038/s41597-019-0300-6

Technical info

Example use of Arrow data from Zenodo and R

# install packages (uncomment to use)
#install.packages("zen4R")
#install.packages("purrr")
#install.packages("arrow")
#install.packages("sfarrow")
library(zen4R)
library(arrow)
library(sfarrow)
library(purrr)
library(ggplot2)
# this will create a directory, use setwd() if you want to
# change the directory to put the files
dir.create("download_zenodo")
# you can list the files in Zenodo using the following script
# z <- get_zenodo(doi= "10.5281/zenodo.18155125")
#names(z$files)
# download the reference files containing the structure for eel and salmon
download_zenodo(doi= "10.5281/zenodo.18155125",
path = "download_zenodo",
files = c("refbast.zip", "refnas.zip", "refeel.zip"))
downloaded_files <- list.files("download_zenodo", full.name = TRUE)
downloaded_path <- file.path(getwd(),"download_zenodo")
# sequentially unzip all files in the same folder
downloaded_files |> purrr::map(\(x)unzip(zipfile=x, exdir =downloaded_path))  
# Open with arrow
ds <- arrow::open_dataset("download_zenodo/refeel_tr_area_are_polygon.parquet")
# you need to use collect() at the end of the query to put the data to memory.
# here I want to know which level will be used. Assessment unit will change to substock
# in the next zenodo version.
ds |> select(are_lev_code) |> unique() |> collect()
mymap <- ds|>
  filter(are_lev_code == "Assessment_unit") |>
    collect()|>
  mutate(geom_polygon = st_as_sfc(geom_polygon, EWKB = TRUE))

#mymap

ggplot(mymap) + geom_sf(aes(geometry = geom_polygon, fill =are_code),color="white",size=.2)+
  scale_fill_viridis_d()+
  theme_minimal()+
  theme(panel.background = element_rect(fill = "light blue"))

# GET ADDITIONAL DATA FROM ICES (ECOREGIONS) -------------
library(httr2)   # or use download.file if you prefer base R
library(sf)      # to read the shapefile or GeoPackage
library(fs)
ecoregions_url <- "https://gis.ices.dk/shapefiles/ICES_ecoregions.zip"   # common historical location
out_dir <- path_temp("ices_ecoregions_dl")
dir_create(out_dir, recurse = TRUE)
zip_path <- path(out_dir, "ICES_ecoregions.zip")
unzip_dir <- path(out_dir, "unzipped")
req <- request(ecoregions_url) |>
  req_user_agent("R (httr2) - ICES ecoregions download") |>
  req_timeout(120)
resp <- req_perform(req, path = zip_path)
dir_create(unzip_dir, recurse = TRUE)
unzipped_files <- unzip(zipfile = zip_path, exdir = unzip_dir)
shp  <- unzipped_files[grepl("\.shp$",  unzipped_files, ignore.case = TRUE)]
# Read with sf
ecoregions_sf <- sf::st_read(shp, quiet = TRUE)
plot(ecoregions_sf["Ecoregion"], main = "ICES Ecoregions")

 R function to get parents areas

library(DBI)
library(RPostgres)
library(dplyr)
con <- DBI::dbConnect(drv=RPostgres::Postgres(),
        dbname = "diaspara",
        host = "myhost",
        user = "diaspara_read",
        password = "************"  
)
area <- dbGetQuery(con, "SELECT
                are_id,
                are_are_id,
                are_code,
                are_lev_code,
                are_ismarine,
                are_name FROM refbast.tr_area_are;")
save(area, file = "area.Rdata")
get_area <- function(are_id, area, tab=data.frame()) {
    if (is.na(are_id)) {
        return(tab)
    } else {
        if (nrow(tab)==0){
            tab <- area[area$are_id == are_id,]
        } else {            
            tab <- rbind(tab, area[area$are_id == are_id,])
        }
        are_id <- tab[nrow(tab), "are_are_id"]
        get_area(are_id, area, tab)    
    }
}
# So we can use a recursive from R
hierar <- get_area(area,are_id = 1275)
# or from postgres
get_area_postgres <- function( con, are_id){
    return(dbGetQuery(con, "SELECT * FROM ref.get_parent_area(1275, 'WGBAST')"))
}
 

Get parents in Postgres : recursive function

 

DROP FUNCTION ref.get_parent_area(integer, TEXT);

CREATE OR REPLACE FUNCTION ref.get_parent_area(_are_id integer, _are_wkg_code TEXT)

RETURNS TABLE(are_id integer, are_are_id INTEGER, are_code TEXT,are_lev_code TEXT, are_ismarine BOOLEAN, are_rivername TEXT)

LANGUAGE plpgsql

AS $function$

BEGIN

RETURN QUERY

WITH RECURSIVE get_parents

AS(

-- anchor member

SELECT r0.are_id,

r0.are_are_id,

r0.are_code,

r0.are_lev_code,

r0.are_ismarine,

r0.are_name

FROM ref.tr_area_are r0 WHERE r0.are_id = $1 and r0.are_wkg_code = $2

UNION

-- recursive term

SELECT r1.are_id,

r1.are_are_id,

r1.are_code,

r1.are_lev_code,

r1.are_ismarine,

r1.are_name

FROM get_parents

JOIN ref.tr_area_are r1 ON r1.are_id = get_parents.are_are_id

WHERE r1.are_wkg_code = $2)

SELECT * FROM get_parents;

END

$function$

;

GRANT ALL ON FUNCTION ref.get_parent_area(integer, text) TO diaspara_read;


hierar <- get_area_postgres(con, are_id = 1275)
# Lets say you have the main_river code as a vector from your points (you know this by spatial join between points and the river segment)
main_rivers <- c("20056363", "20056030")
selected_areas <- dplyr::left_join(data.frame("main_riv"= main_rivers), area, by = join_by("main_riv" == "are_code"))
# to work with more than one argument to the function I would use mapply
ll <- mapply(get_area, selected_areas$are_id, MoreArgs = list(area=area),SIMPLIFY = FALSE)
bind_rows(ll)

Technical info

I just want to get the habitat referential for WGNAS how do I do it ?

 

1 Download the refnas.zip

2 unzip it

3 drag refnas_tr_area_are_polygon.parquet to qgis

4 right click on the layer, select filter, double click on are_lev_code on the left (that's the hierarchical level)

5 indicate in the query level if you want to use the filter level e.g. "are_lev_code" = 'Assessment_unit'

6  the code in column are_code corresponds to the code used by WGNAS

 

Files

fig-final.png

Files (1.8 GB)

Name Size Download all
md5:dad269fc58f6364bef7be8f952a4a162
200.1 MB Download
md5:a4ce888402ebf484efe0598013bdd7fa
200.1 MB Download
md5:e438f59fc82a9843352d73c0fc458bed
428.6 kB Preview Download
md5:3783835eca5cdde090f5afedaf67c121
8.6 MB Download
md5:1107b7d8ae6bbd3e96678e987c467ac2
8.6 MB Download
md5:3b679b965b4f4154f64203b6063c8521
9.6 MB Preview Download
md5:1fdd2ded484dac673972bf25eca95233
17.0 MB Download
md5:8e5373af1d20086cbafb5c68e12aa0cb
18.3 MB Preview Download
md5:972484e8e53ae5ad5af9985585dc36a2
29.3 MB Download
md5:6eb442f6096fe19bb0f047788a433654
31.4 MB Preview Download
md5:19e8eafd76297d96fbd67e195e4154b1
29.4 MB Download
md5:a644447cbf7df0a6830c37eea62046b6
30.1 MB Preview Download
md5:ba8262daa0ef052fccdbb93b8f5cc315
40.9 MB Download
md5:b4788c24f155ea574de32dc74a76017f
42.0 MB Preview Download
md5:54e1efc47db8c042a81c33f52b651a8d
18.9 MB Download
md5:b86d706d7ff715cb07268b095ed06699
19.8 MB Preview Download
md5:d6d9660ba6e724f3cc0057d8a252d5f7
68.2 MB Download
md5:b8165c2d6c30c44922869b549bab699e
70.9 MB Preview Download
md5:9cc366e3b7503ce62684feccc47c292a
8.4 MB Download
md5:ff589312e03eb2eed5e514cfc880e18c
9.3 MB Preview Download
md5:83f67c6d24a383e67b81dfbeaa3118e2
5.7 MB Download
md5:6373a2a761176d41ad12244bb14e7a2d
6.4 MB Preview Download
md5:7befcdf702b822dbd24f58975f044052
2.2 MB Download
md5:860e23bba5ecdc2043720a6d65711614
3.0 MB Preview Download
md5:56647cf8fff01e6f067c798374329c0d
12.6 MB Download
md5:37e9648d529633aaf800bec6bcfa88b0
13.7 MB Preview Download
md5:6902a7666b4a23849b50e300b8081de8
12.5 MB Download
md5:ac0ee7912969b8dc47e689cd6f58b8f6
13.5 MB Preview Download
md5:71a53e994b263d00f1fe99f79edeaf2c
7.7 MB Download
md5:79b6cdd336e2f5b1dffdb65ac186384c
8.2 MB Preview Download
md5:29707fa49d523353c5859f7d24360e5d
19.1 MB Download
md5:88c4ede815b92b14980d0854f9873d68
19.9 MB Preview Download
md5:2ed0751b15c3c8eb7182e1e8c0ac6110
19.3 MB Download
md5:1519886fd7212197ebb7089f57c17157
20.6 MB Preview Download
md5:09983841bf2fcc79db22dec3167680ac
4.4 MB Download
md5:f7fdd07f856874d1e71d531c3044b141
5.2 MB Preview Download
md5:69ee699c030626e61d29d45c7cf95d64
8.8 MB Download
md5:d400f67f3dec9386b9c66b28b4987009
10.1 MB Preview Download
md5:2f8496b9d2901f47f928d7ab3140e242
2.5 MB Download
md5:371bd6bfb74c147c314ff47045375f1a
3.3 MB Preview Download
md5:d67883cb06697cee892b6c07272f2b92
57.9 MB Download
md5:b53b242bf940849cbf43113852338acd
59.2 MB Preview Download
md5:102c74059907ac95d004c573945b9a25
5.1 MB Download
md5:b96df827eb8839767a5dc29cb14c2800
5.7 MB Preview Download
md5:6674aa11c9ff34e07a3dcc125ce97d7a
1.7 MB Download
md5:b02cbb968d5eb4ab66af42b8a0f280ec
2.3 MB Preview Download
md5:f27109140803474187eb244be24632e1
47.8 kB Download
md5:bc01182999069f1c2eee111be2506426
5.5 MB Download
md5:baa410f2426b66a32d2a6abc883b1bd0
84.0 kB Download
md5:e744957cebebe0fc4e6b856c66293104
6.3 kB Preview Download
md5:ce5612fa8e809407a92637881e2f0de5
6.7 MB Preview Download
md5:20097a254f002a05143ad1744daf09d8
159.9 MB Preview Download
md5:9f59ba55b66e59d4bd0d0214c5bc666a
33.4 MB Preview Download
md5:b686f7efb96d41939c79aec463c631aa
286.9 MB Preview Download
md5:91c4e863eb4dc9637740b551f55bf9c5
128.2 MB Preview Download

Additional details

Related works

Funding

European Climate, Infrastructure and Environment Executive Agency
EMFAF-2023-PIA-FisheriesScientificAdvice 101155914

Dates

Created
2026-01-05
0.0.2

Software

Repository URL
https://github.com/DIASPARAproject
Programming language
SQL , R