ropensci / CoordinateCleaner

Automated flagging of common spatial and temporal errors in biological and palaeontological collection data, for the use in conservation, ecology and palaeontology.

Home Page:https://docs.ropensci.org/CoordinateCleaner/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

SarahVal opened this issue · comments

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