Closed ASeatonSpatial closed 3 years ago
The root cause of the is.na
is a bug in the sp
1.4-4 package, for sp:::is.na.CRS
, that I've now reported upstream and made a workaround in inlabru, commit dbcf8c2.
However, with your rgdal and sp versions I wouldn't have expected inlabru to call is.na at all, and the other unpredictabilities are also a bit strange. Is it possible you have PROJ4? (PROJ4 is meant to still work, but I don't have access to a PROJ4 system to test things on). Check before and after the raster::crs()
call what inlabru:::fm_has_PROJ6()
returns (in a fresh R session).
Confirmed bug in sp, and the inlabru workaround works, and the code was triggered by pre-PROJ6 on Ubuntu 18.04.
I couldn't create a reproducible example, something seems strange with this specific situation and I can't pin down what.
This works using the gorillas data removing crs information from the mesh and the
sp
polygons object and then creating ipoints:On my example I get the following error
Things get weirder... if I do
raster::crs(study_area)
before I runipoints()
then it works. I couldn't quite believe this, I've done it 4 or 5 times both ways and it never works without it and always works with it.I really don't get this,
crs(study_area)
should just be retrieving the crs information, not changing anything.Traceback when it doesn't work is
Running debug I think the issue is
domain_crs <- fm_ensure_crs(domain$crs)
.From playing around in debug:
It seems
fm_ensure_crs(domain$crs)
does not return a CRS object thatfm_crs_is_null()
likes.Some more info on
domain_crs
:I'm stumped from here. This doesn't happen when I debug on the gorillas data and I can't figure out what is funny about my example here. I think this issue will happen whenever
fm_ensure_crs()
is called since it returnssp::CRS(NA_character_)
and this throws an error:The only connection I can see with the weird
raster::crs()
thing is that the outputCRS arguments: NA
appears both there and indomain_crs
. I have the mesh and polygon saved as .RDS files, they are not big, I can provide them if that would be helpful.