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

Speeding up gwr.predict #22

Open
nikosGeography opened this issue Jan 30, 2023 · 0 comments
Open

Speeding up gwr.predict #22

nikosGeography opened this issue Jan 30, 2023 · 0 comments

Comments

@nikosGeography
Copy link

I have one dependent and two independent variables and I want to predict at new locations using the gwr.predict. I was wondering if there is a way to speed up the function because it is very slow. For example, when using gwr.basic, I can utilize the parameters parallel.method and parallel.arg. Is there a way to use them in the gwr.predict function as well?

Here is the code I am using:

library (GWmodel)
library(raster)
library(sp)

wd = "path/"
provoliko = "EPSG:7767"

tirs = raster(paste0(wd, "tirs.tif"))
pop = raster(paste0(wd, "pop.tif"))
s = stack(pop, tirs)
names(s) = c("pop", "tirs")
regpoints <- rasterToPoints(s, spatial = TRUE)

block.data = read.csv(paste0(wd, "block.data.csv"))

coordinates(block.data) <- c("x", "y")
proj4string(block.data) <- provoliko

dist = GWmodel::gwr.dist(dp.locat = coordinates(block.data), rp.locat = coordinates(regpoints), focus = 0, p = 2, theta = 0, longlat = F)

eq1 <- ntl ~ pop + tirs

abw = bw.gwr(eq1, 
             data = block.data, 
             approach = "CV", 
             kernel = "gaussian",
             adaptive = TRUE, 
             p = 2, 
             longlat = FALSE, 
             parallel.method = "omp",
             parallel.arg = "omp")

p = gwr.predict(eq1, 
                          data = block.data, 
                          predictdata = regpoints, 
                          bw = abw, 
                          kernel = "gaussian", 
                          adaptive = TRUE, 
                          p = 2,
                          theta = 0, 
                          longlat = FALSE, 
                          dMat1 = dist)
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

1 participant