edzer / sp

Classes and methods for spatial data
http://edzer.github.io/sp/
128 stars 27 forks source link

Correct how is.na.CRS looks for the wkt comment #128

Closed finnlindgren closed 1 year ago

finnlindgren commented 1 year ago

Old version of is.na.CRS incorrectly looked for a proj4string slot in the CRS object to extract a wkt comment from, but should extract the wkt comment from a comment on the CRS object itself. Discussed at https://github.com/inlabru-org/inlabru/issues/178

> sp::set_evolution_status(2L)
[1] 2
inlabru:devel> is.na(sp::CRS("+proj=geocent +units=km"))
Error in slot(x, "proj4string") : 
  no slot of name "proj4string" for this object of class "CRS"

> sp:::is.na.CRS
function (x) 
{
    is.na(x@projargs) && is.null(comment(slot(x, "proj4string")))
}

# What I believe is the correct approach:
> x<-sp::CRS("+proj=geocent +units=km")
> is.na(x@projargs) && is.null(comment(x))
[1] FALSE