The comparison of the projection information in predict.gstat seems stricter then testing for identical projections with the sp of sf packages. I can believe there is an explanation but can't find it. Example with data attached but in outline:
Running a model fit fails due to different projects
> nm <- names(grd)[1]
> m <- idw(formula(paste0(nm," ~ 1")),obs,grd)
[1] "+proj=longlat +datum=WGS84 +no_defs"
[1] "+proj=longlat +datum=WGS84 +no_defs"
Error in predict.gstat(g, newdata = newdata, block = block, nsim = nsim, :
var1 : data item in gstat object and newdata have different coordinate reference systems
In addition: Warning messages:
1: In proj4string(d$data) :
CRS object has comment, which is lost in output
2: In proj4string(newdata) :
CRS object has comment, which is lost in output
The test performed by predict.gstat (line 41 in R code) would seem to be equivalent to
The comparison of the projection information in predict.gstat seems stricter then testing for identical projections with the sp of sf packages. I can believe there is an explanation but can't find it. Example with data attached but in outline:
With two objects of class sf called obs and grd
passes a comparison of projections
and when converted to sp
Running a model fit fails due to different projects
The test performed by predict.gstat (line 41 in R code) would seem to be equivalent to
This fails since the wkt (which as shown above is different) is copied into the comment attribute of the proj4string attribute of the data
Full example data and code projection_test.zip