ropensci / CoordinateCleaner

Automated flagging of common spatial and temporal errors in biological and palaeontological collection data, for the use in conservation, ecology and palaeontology.
https://docs.ropensci.org/CoordinateCleaner/
79 stars 21 forks source link

cc_urb : error when cropping urban ref with obs extent is null #65

Open SarahVal opened 2 years ago

SarahVal commented 2 years ago

Hi, I encountered a small bug when applying cc_urb function, raising the following error message:

Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘proj4string<-’ for signature ‘"NULL", "character"’

I found out that the result of cropping the ref raster with the observations extent (line 83) was null, thus an error happened when trying to set it a projection (line 84). I fixed the issue by moving the proj4string function inside the if/else structure : if (is.null(ref)) { out <- rep(TRUE, nrow(x)) } else { proj4string(ref) <- wgs84 out <- is.na(sp::over(x = dat, y = ref)[, 1]) }

Cheers, Sarah