Closed karpfen closed 2 years ago
Thanks for reporting! I won't have time to dig into this for about two weeks. I would happily except a PR if you find a solution.
.calc_ecoregions()
should return NA if no intersection is found. I thus expect the bug to occur somewhere here:
What this is supposed to do is to just row bind the data frames if no Polygon returned NA or copy the column names and fill in NA for Polygons where NA has been returned. I hope this can get you started in finding a fix.
Cool, thanks for the hint! I'll start working on a PR next week, I'll be in touch.
@goergen95 I just wrote a fix on my fork (s. here), however before doing a PR I want to make sure it works and write a unit test that covers the error I described above.
However, I'm unfamiliar with the except_snapshot
tests and they seem to fail even when I just clone the repo and run devtools::test()
without any changes to the code. Are there any special requirements for the enivonment I have to consider in order to be able to test and check?
My Setup: R version 4.2.1 devtools: 2.4.4 testthat: 3.1.4
Update: I read up a bit on snapshot tests now and figured out what the problem with the unit tests was. Some of the snapshots in the repo contain likes like "# i Use print(n = ...)
to see more rows, and colnames()
to see all variable names"
On my machine these weren't generated, that's what caused the unit tests for me to fail. But knowing that I was able to test and check my changes. I'll send a PR.
Update: I read up a bit on snapshot tests now and figured out what the problem with the unit tests was. Some of the snapshots in the repo contain likes like "# i Use
print(n = ...)
to see more rows, andcolnames()
to see all variable names" On my machine these weren't generated, that's what caused the unit tests for me to fail. But knowing that I was able to test and check my changes. I'll send a PR.
Setting options(pillar.advice = TRUE)
before running tests should do the trick. This is done internally here:
Could you please try and install dev version via remotes::install_github("mapme-initiative/mapme.biodiversity", ref = "101-teow-ecoregion-contains-unexpected-results")
and check if that fixes your issue?
Just tried it, it works as expected now, thanks!
thanks for the quick feedback. the changes are now merged into main.
mapme.biodiversity
version: 0.2.1When calculating the ecoregions of two regions where one of them lies outside of the TEOW data, the package writes the ecoregion and area of the first region into both result regions. The reproducible example below shows this behavior.