I am using the package GWmodel to predict at a finer spatial scale. Basically, I want my output to be a single raster layer. For the GWR, I am using one dependent and 2 independent variables. I don't know how to create the prediction raster.
When using only one independent variable it's easy. For example: library(GWmodel) library(sp) library(raster) wd = "path/" provoliko = "EPSG:7767" # this is my fine res raster tirs = raster(paste0(wd, "tirs.tif")) regpoints <- as(tirs, "SpatialPoints") # this df contains the coarse res variables block.data = read.csv(paste0(wd, "block.data.csv")) coordinates(block.data) <- c("x", "y") proj4string(block.data) <- provoliko eq1 <- ntl ~ tirs abw = bw.gwr(eq1, data = block.data, approach = "AIC", kernel = "gaussian", adaptive = TRUE, p = 2, parallel.method = "omp", parallel.arg = "omp") ab_gwr = gwr.basic(eq1, data = block.data, regression.points = regpoints, bw = abw, kernel = "gaussian", adaptive = TRUE, p = 2, F123.test = FALSE, cv = FALSE, parallel.method = "omp", parallel.arg = "omp") ab_gwr sp <- ab_gwr$SDF sf <- st_as_sf(sp) # intercept intercept = as.data.frame(sf$Intercept) intercept = SpatialPointsDataFrame(data = intercept, coords = regpoints) gridded(intercept) <- TRUE intercept <- raster(intercept) raster::crs(intercept) <- provoliko # slope slope = as.data.frame(sf$tirs) slope = SpatialPointsDataFrame(data = slope, coords = regpoints) gridded(slope) <- TRUE slope <- raster(slope) raster::crs(slope) <- provoliko gwr_pred = intercept + slope * s writeRaster(gwr_pred, paste0(wd, "ntl_gwr.tif"), overwrite = TRUE) When using multiple independent variables, I tried to stack them before I convert them to spatialPoints, but then I don't know what to set in the slope parameter. -- Tziokas Nikolaos Cartographer Tel:(+44)07561120302 LinkedIn <http://linkedin.com/in/nikolaos-tziokas-896081130> [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo