I am trying to conduct IDW using gstat, however, I keep getting this :
Error in predict.gstat(g, newdata = newdata, block = block, nsim = nsim, : var1 : data item in gstat object and newdata have different coordinate reference systems. However, when I check the CRS of both grd and no2_spdf, they are the exact same.
Here is my code
Create an empty grid where n is the total number of cells
grd <- as.data.frame(spsample(as_Spatial(no2_spdf), "regular", n=50000))
names(grd) <- c("X", "Y")
coordinates(grd) <- c("X", "Y")
gridded(grd) <- TRUE # Create SpatialPixel object
fullgrid(grd) <- TRUE # Create SpatialGrid object
Add P's projection information to the empty grid
crs(grd) <- CRS("+init=epsg:4269")
grd
Interpolate the grid cells using a power value of 2 (idp=2.0)
inter <- gstat::idw(Arithmetic.Mean ~ 1, no2_spdf, newdata = grd, idp = 2.0)
Error in predict.gstat(g, newdata = newdata, block = block, nsim = nsim, : var1 : data item in gstat object and newdata have different coordinate reference systems.