Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add read abiotic ranges function #195

Open
wants to merge 2 commits into
base: dev_nextrelease
Choose a base branch
from
Open

Conversation

hansvancalster
Copy link
Contributor

A function to read the data from https://zenodo.org/records/10533792.

This is a quick and dirty implementation - so a good review round will be needed.

@florisvdh I haven't updated NEWS or bumped version because I imagine that you may prefer setting up a development branch first? Otherwise I can add it to this branch, just let me know.

@florisvdh
Copy link
Member

@hansvancalster thanks for giving this a start! As already talked about, we'll look into this further together. I plan to come back to it later this week.

The target branch should be dev_nextrelease (not main), and it has got updated recently. So you need to update the target branch of this PR (I suppose you can, otherwise I can) and pull dev_nextrelease into read_far.

If you want a clean start instead, then, after pulling dev_nextrelease, you can either start a new branch from there, cherry-pick ebafc10 and start a new PR, or update the existing branch by rebasing read_far onto dev_nextrelease, then force-push here.

@florisvdh
Copy link
Member

florisvdh commented Feb 3, 2025

> test <- read_abiotic_ranges()
> glimpse(test)
Rows: 1,149
Columns: 18
$ Habitatsubtype        <chr> "1310_pol", "1310_pol", "1310_pol", "1310_zk", "1310_zk", "1310_zk", "1310_zk", "1310…
$ Subtype               <chr> "", "", "", "", "", "", "", "Suaedetum", "", "", "Sagino maritimae-Cochlearietum", "C$ Milieucompartiment    <chr> "Bodem", "Grondwater", "Lucht", "Grondwater", "Grondwater", "Inundatiewater", "Inunda…
$ Variabele             <chr> "Chloride", "Chloride", "Stikstofdepositie", "Chloride", "Gemiddelde voorjaarsgrondwa$ Afkorting             <chr> "Cl", "Cl", "N-depositie", "Cl", "GVG", "Hoogte t.o.v. getij", "Overstromingsfrequent…
$ Eenheid               <chr> "mg/l", "mg/l", "kg N/ha/j", "mg/l", "m - mv", "m", "%", "%", "kg N/ha/j", "m - mv", …
$ Toetswijze...bepaling <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "$ Teken                 <chr> "OG - BG", ">", "<", ">", "OG - BG", "", "OG - BG", "OG - BG", "<", "OG - BG", "OG - …
$ Abiotisch.bereik      <chr> "0 - 70", "3000", "23", "3000", "-0,13 - 0,03", "GHW", "50 - 85", "41 - 61", "23", "0$ Waarde.1              <chr> "0", "3000", "", "3000", "-0,13", "GHW", "50", "41", "", "0,22", "3000", "300", "", "
$ Waarde.2              <chr> "70", "", "23", "", "0,03", "", "85", "61", "23", "0,41", "10000", "3000", "21", "", …
$ WaardeNum1            <chr> "0", "3000", "", "3000", "-0,13", "", "50", "41", "", "0,22", "3000", "300", "", "300$ WaardeNum2            <chr> "70", "", "23", "", "0,03", "", "85", "61", "23", "0,41", "10000", "3000", "21", "", …
$ N.gunstig             <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N$ Status                <chr> "Lk", "Lk", "Lg", "Lk", "Lk", "Lk", "Lk,Lk", "Lk", "Lg", "Lk, Lk", "Lk", "Lk", "Lg", …
$ Referentie            <chr> "Schamin\xe9e et al. 1998", "Ertsen et al. 1998", "ANB 2015", "Ertsen et al. 1998", "
$ Opmerking             <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "$ Wijziging             <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N

Dropping here some thoughts to discuss live.

  • use applicable elements of other n2khab reading functions like read_habitatsprings() as a template (but don't use .data in tidyselect expressions, it's deprecated). This explains several of below.
  • explicitly distinguish a far data source (for read_far()) (or favenv)
    • using directory 10_raw/far
    • explicitly referring the version in the function
    • adding it into our draft overview
    • change version name in Zenodo to e.g. far_v1 on Zenodo
    • preferably also include this data source in the n2khab-data-raw collection community on Zenodo, referred by the n2khab package
    • preferably provide both English & Dutch metadata + English title in the Zenodo page (cf https://zenodo.org/records/6652962)
  • should we use 'abiotic' or 'environmental'? TBD
  • downloading only when missing (actually that is a framework which we plan to implement in a general way, using a built-in dataset of all data source versions and their DOIs)
  • style & structure of the result, including column names: https://inbo.github.io/n2khab/CONTRIBUTING.html#coding-tools
  • consider the option to return either English or Dutch content, e.g. as in read_types(lang = ), which makes use of the namelist data source.
  • use factors where appropriate (many of these variables), preferably using a sensible level order. Some of these should be interconnected, e.g. the environmental variable & its abbreviation
  • match column names and factor levels with other objects; the first three variables should be aligned with output from read_types(), read_schemes()
  • empty strings or NAs?
  • units:
    • don't use Dutch unit abbreviations in the result (and I would recommend: the data source), e.g. 'j' is now used for year; also 'm-mv' is Dutch.
    • actually 'm-mv' is not a real unit. It is 'm', but using a local vertical CRS where zero is the soil surface level and with a declared direction. This is part of the environmental variable's definition.
  • use UTF-8 for strings where this isn't the case (e.g. Referenties above). See e.g.

    n2khab/R/read_soilmap.R

    Lines 383 to 384 in 8be10bb

    soilmap %>%
    convertdf_enc(from = "latin1", to = "UTF-8") %>%
  • optionally consider something as in read_habitatquarries() regarding the literature references

@hansvancalster hansvancalster changed the base branch from main to dev_nextrelease February 4, 2025 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants