Skip to contents

The function crosswalk() provides an easy mapping from habitat codes in one classification system to another.

From EUNIS 2012 to EUNIS Marine 2022

crosswalk(
  code = c("A3.4", "A3.5"),
  from = "EUNIS_2012",
  to = "EUNIS_M_2022",
  unnest = TRUE
)
#> # A tibble: 64 × 2
#>    eunis_2012_code eunis_m_2022_code
#>    <chr>           <chr>            
#>  1 A3.4            MA133            
#>  2 A3.4            MA134            
#>  3 A3.4            MA135            
#>  4 A3.4            MA136            
#>  5 A3.4            MA137            
#>  6 A3.4            MB13             
#>  7 A3.4            MB131            
#>  8 A3.4            MB1311           
#>  9 A3.4            MB1312           
#> 10 A3.4            MB1313           
#> # ℹ 54 more rows

From EUNIS Marine 2019 to EUNIS 2012

crosswalk(
  code = c("MH152", "MH2331"),
  from = "EUNIS_M_2019",
  to = "EUNIS_2012",
  unnest = TRUE
)
#> # A tibble: 2 × 2
#>   eunis_m_2019_code eunis_2012_code
#>   <chr>             <chr>          
#> 1 MH152             A7.12          
#> 2 MH2331            A7.231

From EUNIS Marine 2022 to the European Red List of Habitats

crosswalk(
  code = c("MH152", "MH2331", "MA146", "MD55"),
  from = "EUNIS_M_2022",
  to = "RL",
  unnest = TRUE
)
#> # A tibble: 4 × 2
#>   eunis_m_2022_code rl_code
#>   <chr>             <chr>  
#> 1 MH152             NA     
#> 2 MH2331            NA     
#> 3 MA146             A1.1xx 
#> 4 MD55              A5.27

One to many mappings

Note that some mappings are one to many, e.g. "MA12" in EUNIS Marine 2019 maps to the following Habitats Directive Annex I habitat codes: "8330", "1160", "1170" and "1130". That is why, by default, the to column is a list-column.

crosswalk(
  code = c("M", "MA1", "MA11", "MA12"),
  from = "EUNIS_M_2019",
  to = "Annex_I"
)
#> # A tibble: 4 × 2
#>   eunis_m_2019_code annex_i_code
#>   <chr>             <list>      
#> 1 M                 <chr [1]>   
#> 2 MA1               <chr [1]>   
#> 3 MA11              <chr [1]>   
#> 4 MA12              <chr [4]>

You need to use unnest = TRUE to flatten out the table of mappings and convert the to list-column to a character vector column.

crosswalk(
  code = c("M", "MA1", "MA11", "MA12"),
  from = "EUNIS_M_2019",
  to = "Annex_I",
  unnest = TRUE
)
#> # A tibble: 7 × 2
#>   eunis_m_2019_code annex_i_code
#>   <chr>             <chr>       
#> 1 M                 NA          
#> 2 MA1               NA          
#> 3 MA11              NA          
#> 4 MA12              8330        
#> 5 MA12              1160        
#> 6 MA12              1170        
#> 7 MA12              1130