Is the warning from gstat() spurious? Warning in proj4string(obj): CRS object has comment, which is lost in output; in tests, see
Opened this issue · 1 comments
MatthieuStigler commented
When using gstat
on an object with a crs, I get the warning:
Warning message:
In proj4string(obj) :
CRS object has comment, which is lost in output; in tests, see
https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
I am puzzled as the resulting crs of gstat-> predict
seems the same as both inputs? Is this a spurious message, or a serious warning that I am doing something wrong (using an outdated crs?)?
Thanks!
library(gstat)
library(sf)
#> Linking to GEOS 3.10.1, GDAL 3.4.0, PROJ 8.2.0; sf_use_s2() is TRUE
library(sp)
packageVersion("gstat")
#> [1] '2.0.9'
packageVersion("sf")
#> [1] '1.0.6'
packageVersion("rgdal")
#> [1] '1.5.28'
## prepare points and grid
nc = st_read(system.file("shape/nc.shp", package="sf"), quiet=TRUE)
nc_points = st_sf(x=runif(6), geometry=st_sample(nc[1:3, ], 6) )
nc_grid <- st_make_grid(nc, n = 3)
nc_points_sp <- as(nc_points, "Spatial")
nc_grid_sp <- as(nc_grid, "Spatial")
## run gstat on sf objects
gs_out <- gstat(formula = x ~ 1, data = nc_points,
maxdist = 80000,
set = list(idp = 2))
z <- predict(gs_out, nc_grid[1])
#> Warning in proj4string(obj): CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> [inverse distance weighted interpolation]
st_crs(z) == st_crs(nc_grid)
#> [1] TRUE
st_crs(z) == st_crs(nc_points)
#> [1] TRUE
## and on sp
gs_out_sp <- gstat(formula = x ~ 1, data = nc_points_sp,
maxdist = 80000,
set = list(idp = 2))
z_sp <- predict(gs_out_sp, nc_grid_sp[1])
#> Warning in proj4string(obj): CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> [inverse distance weighted interpolation]
st_crs(z_sp) == st_crs(nc_grid_sp)
#> [1] TRUE
st_crs(z_sp) == st_crs(nc_points_sp)
#> [1] TRUE
Created on 2022-03-21 by the reprex package (v2.0.1)
edzer commented
spurious.