I have two raster layers, one coarse resolution and one fine resolution. My goal is to extract GWR's coefficients (intercept and slope) and apply them to my fine resolution raster.
I can do this easily when I perform simple linear regression. For example: library(terra) library(sp) # focal terra tirs = rast("path/tirs.tif") # fine res raster ntl = rast("path/ntl.tif") # coarse res raster # fill null values tirs = focal(tirs, w = 9, fun = mean, na.policy = "only", na.rm = TRUE) gf <- focalMat(tirs, 0.10*400, "Gauss", 11) r_gf <- focal(tirs, w = gf, na.rm = TRUE) r_gf = resample(r_gf, ntl, method = "bilinear") s = c(ntl, r_gf)names(s) = c('ntl', 'r_gf') model <- lm(formula = ntl ~ tirs, data = s) # apply the lm coefficients to the fine res raster lm_pred = model$coefficients[1] + model$coefficients[2] * tirs But when I run GWR, the slope and intercept are not just two numbers (like in linear model) but it's a range. For example, below are the results of the GWR: *Summary of GWR coefficient estimates*: Min. 1st Qu. Median 3rd Qu. Max. Intercept -1632.61196 -55.79680 -15.99683 15.01596 1133.299 tirs20 -42.43020 0.43446 1.80026 3.75802 70.987 My question is how can extract GWR model parameters (intercept and slope) and apply them to my fine resolution raster? In the end I would like to do the same thing as I did with the linear model, that is, *GWR_intercept + GWR_slope * fine resolution raster*. Here is the code of GWR: library(GWmodel) library(raster) block.data = read.csv(file = "path/block.data00.csv") #create mararate df for the x & y coords x = as.data.frame(block.data$x) y = as.data.frame(block.data$y) sint = as.matrix(cbind(x, y)) #convert the data to spatialPointsdf and then to spatialPixelsdf coordinates(block.data) = c("x", "y")#gridded(block.data) <- TRUE # specify a model equation eq1 <- ntl ~ tirs dist = GWmodel::gw.dist(dp.locat = sint, focus = 0, longlat = FALSE) abw = bw.gwr(eq1, data = block.data, approach = "AIC", kernel = "tricube", adaptive = TRUE, p = 2, longlat = F, dMat = dist, parallel.method = "omp", parallel.arg = "omp") ab_gwr = gwr.basic(eq1, data = block.data, bw = abw, kernel = "tricube", adaptive = TRUE, p = 2, longlat = FALSE, dMat = dist, F123.test = FALSE, cv = FALSE, parallel.method = "omp", parallel.arg = "omp") ab_gwr You can download the csv from here <https://drive.google.com/drive/folders/1V115zpdU2-5fXssI6iWv_F6aNu4E5qA7?usp=sharing>. The fine resolution raster I am using: tirs = rast(ncols=407, nrows=342, nlyrs=1, xmin=509600, xmax=550300, ymin=161800, ymax=196000, names=c('tirs'), crs='EPSG:27700') -- 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