inbo / camtrapdp

R package to read and manipulate Camera Trap Data Packages (Camtrap DP)
https://inbo.github.io/camtrapdp/
Other
5 stars 0 forks source link

Taxonomic names cannot be NULL #143

Open peterdesmet opened 2 days ago

peterdesmet commented 2 days ago

When writing to datapackage.json, ranks that have NA are written as NULL:

{
      "scientificName": "Ardea",
      "taxonID": "https://www.checklistbank.org/dataset/COL2023/taxon/32FH",
      "taxonRank": "genus",
      "family": null,
      "order.": null,
      "vernacularNames": {
        "eng": "great herons",
        "nld": "reigers"
}

This causes a validation error:

──────────────────────────────────────────────────────────────────────── Tables ────────────────────────────────────────────────────────────────────────
                                                            dataset                                                             
┏━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Row  ┃ Field ┃ Type          ┃ Message                                                                                       ┃
┡━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ None │ None  │ package-error │ The data package has an error: None is not of type 'string' at property 'taxonomic/0/family'  │
│ None │ None  │ package-error │ The data package has an error: None is not of type 'string' at property 'taxonomic/1/family'  │
│ None │ None  │ package-error │ The data package has an error: None is not of type 'string' at property 'taxonomic/3/family'  │
│ None │ None  │ package-error │ The data package has an error: None is not of type 'string' at property 'taxonomic/4/family'  │
│ None │ None  │ package-error │ The data package has an error: None is not of type 'string' at property 'taxonomic/5/family'  │
│ None │ None  │ package-error │ The data package has an error: None is not of type 'string' at property 'taxonomic/8/family'  │
│ None │ None  │ package-error │ The data package has an error: None is not of type 'string' at property 'taxonomic/9/family'  │
│ None │ None  │ package-error │ The data package has an error: None is not of type 'string' at property 'taxonomic/11/family' │
└──────┴───────┴───────────────┴───────────────────────────────────────────────────────────────────────────────────────────────┘

We should probably set those to NULL (not NA) in update_taxonomic(), which will cause them to be removed when writing.

peterdesmet commented 1 day ago

Maybe caused by:

https://github.com/inbo/camtrapdp/blob/72f73107eafc1f69461c9a863cf4f38353938cc6/R/taxonomic.R#L18-L19