gdauby / ConR

ConR
https://gdauby.github.io/ConR/
13 stars 3 forks source link

EOO is NA for presences in a straight line #29

Open AMBarbosa opened 1 year ago

AMBarbosa commented 1 year ago

In my use case, it is not too uncommon for some species to have only one or two presence points in the study area. In these cases, the EOO "polygon" is actually a point or a line, so it has an area of zero. IUCN guidelines say that, in such cases, EOO should be set as =AOO. Actually I see this in the code for getAnywhere(.IUCN.comp): if (EOO < AOO) EOO <- AOO. However, this seems to get lost somewhere, as the result of IUCN.eval() still says EOO is NA for these species. Maybe it should be changed to if (is.na(EOO) || EOO < AOO) EOO <- AOO?

I've also tried specifying buff_width to get an actual polygon around the occurrences, but it seems to be ignored, as well as the draw.poly.EOO argument.

Here's a reproducible example:

(example <- structure(list(lon = c(-2.59487105548141, -2.01867048441999), lat = c(39.1635112135211, 38.9798640743379), species = c("myspecies", "myspecies")), row.names = c(1L, 2L), class = "data.frame"))
#         lon      lat   species
# 1 -2.594871 39.16351 myspecies
# 2 -2.018670 38.97986 myspecies

ConR::IUCN.eval(example,
                buff_width = 10,  # apparently ignored
                parallel = TRUE,
                write_results = FALSE,
                draw.poly.EOO = TRUE)
#  |=================================================================| 100%
#           EOO AOO Nbe_unique_occ. Nbe_subPop Nbe_loc Category_CriteriaB
# myspecies  NA   8               2          2       2                 EN
#           Category_code Category_AOO Category_EOO
# myspecies        EN B2a           EN         <NA>

image

A fix would be greatly appreciated! Cheers

gdauby commented 1 year ago

Hello, thanks for your comment. In fact the condition if (EOO < AOO) EOO <- AOO is applied only if EOO can be calculated. But if you have one or two occurrences EOO cannot be calculated. The test for a straight line is only done when there is more than 3 pairs of unique coordinates. Whether EOO should be set equal to AOO if it cannot be calculated is a good question. I should check what the guidelines says.

AMBarbosa commented 1 year ago

I figure if the condition applies to 3 presences in a straight line, it should also apply to 2 presences (which are necessarily in a straight line), and ultimately to one presence as well. The extent (area) of a line or a point should be zero; it should only be NA if there were no presence points at all. If there is an AOO, to me it only makes sense to have an EOO too.

gdauby commented 1 year ago

You are right, I'll modify this asap

gdauby commented 1 year ago

Dear @AMBarbosa

since I am currently working on a new version of the package, I updated the developmental version which is quite different from the original one. I cannot maintain both packages in parallel. The ConR currently on CRAN will probably be achived at some point and replaced by the new version.

I therefore updated the new version accordingnly and I suggest you try this one

devtools::install_github("gdauby/ConR@devel")

library(ConR)

(example <- structure(list(lon = c(-2.59487105548141, -2.01867048441999), lat = c(39.1635112135211, 38.9798640743379), species = c("myspecies", "myspecies")), row.names = c(1L, 2L), class = "data.frame"))

criterion_B(x = example )

The ConR::IUCN.eval not longer exist and has been replaced by criterion_B.

Let me know if you have any issue or questions.

Concerning this issue, note that EOO is not set equal to AOO if EOO < AOO or if EOO cannot be computed which is the case when there are less than 3 unique pairs of coordinates. If pairs of coordinates form a straitgh line (tested when at least 3 unique pairs of coordinates), 'noise' is added to coordinates to avoid the straight line (no buffer anymore).