Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the warning from gstat() spurious? Warning in proj4string(obj): CRS object has comment, which is lost in output; in tests, see #101

Open
MatthieuStigler opened this issue Mar 21, 2022 · 1 comment

Comments

@MatthieuStigler
Copy link

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
Copy link
Member

edzer commented Mar 21, 2022

spurious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants