i have problem autokrig function , try make reproducible example here:
library(automap) library(raster) library(dismo) bio <- getdata("worldclim", var="bio", res=10) bio1 <- raster(bio, layer=1) bio12 <- raster(bio, layer=12) predictors <- stack(bio1, bio12) bg <- randompoints(bio1, 50) data <- extract(predictors, bg) data <- cbind(bg,data) data <- data.frame(data) coordinates(data)=~x+y proj4string(data) = crs("+proj=longlat +datum=wgs84 +ellps=wgs84 +towgs84=0,0,0") kg <- autokrige(bio1~bio12, data, new_data=predictors) this result in:
error in autokrige(bio1 ~ bio12, data, new_data = predictors) : either input_data or new_data in longlat, please reproject. input_data: +proj=longlat +datum=wgs84 +ellps=wgs84 +towgs84=0,0,0 new_data: +proj=longlat +datum=wgs84 +ellps=wgs84 +towgs84=0,0,0 i same error original data. appreciate help.
if read file, tell why throwing error.
autokrige performs checks on coordinate systems of input_data , new_data. if 1 or both na, assigned projection of other. if have different projections, error raised. if 1 or both has non-projected system (i.e. latitude-longitude), error raised. error raised because 'gstat use spherical distances when data in geographical coordinates, usual variogram models typically not non-negative definite on sphere, , no appropriate models available' (edzer pebesma on r-sig-geo).
it looks need project data before calling autokrige.
Comments
Post a Comment