# Accounting for the point spread function during geographically weighted regression analysis in R

Hi,

I am investigating the effect of point spread function (PSF) during spatial downscaling. The process of spatial downscaling involves two steps:

1. regression (GWR in my case)
2. area-to-point Kriging (ATPK).

In order to investigate the effect of the PSF I have to take it into account in both steps. My question is this:
Is there any package in `R` that takes into account the PSF during geographically weighted regression analysis?
I am asking this because during ATPK, I insert the values of the PSF into the function (I am using the `atakrig` package). For example, in the `atakrig` package I insert:

`pan.d = discretizeRaster(pan, 100, type = "value", sigma = 0.2, psf = "gau")`

Many thanks.

I have found the solution (at least theoretically). In order to account for the PSF during regression using raster data (one coarse image and one fine resolution image), the fine resolution image needs to be upscaled to match the pixel size of the coarse image. This upscaling should be done using a Gaussian filter (i.e., the PSF which is assumed to be Gaussian). If anyone knows a package that upscales an image using a Gaussian filter then please post it here.

1 Like

for the Gaussian test currently I'm using the library(lmtest)

you can use for it : (link = "identity")
for inverse Gaussian : link = "1/mu^2"

glm(Y~X1+X2+X3+X4, family = Gamma(link = "identity"), data = data)

hope this is helpful

Kind Regards

the `data = *some df*` part implies that I have to create a `df` containing the pixel values of my raster data set (one column Y which will have the pixel values of my coarse resolution raster and, one column X which will have the pixel values of my fine resolution raster). The fine resolution raster will produce more rows in the `df`, compared to the coarse resolution raster, because it has more pixels. To be more precise, when I convert the pixel values of the two raster into a `data.frame`, I'm getting a `data.frame` with 4230 rows for the coarse resolution raster and, and the other `data.frame` has 3982125 rows for my fine resolution raster.
I hope I explained clearly what troubles me in your method. What are your thoughts about this? In case you want I attached my dataset (the ntl is the coarse resolution band and the pan is the fine)

Here's how I do it:

pan = raster("path/pan15.tif") #the fine resolution raster
ntl = raster("path/ntl.tif") #the coarse resolution raster

vals_ntl <- as.data.frame(values(ntl)) #4230 rows
vals_pan <- as.data.frame(values(pan)) #3982125 rows

Many thanks

I found the solution. The code is is this:

``````library(OpenImageR)

r = raster("path/pan15.tif")

m = as.matrix(r)

psf = down_sample_image(m,
factor = 4.6,
gaussian_blur = T,
gauss_sigma = 0.5 * 100) #sigma * pixel size
extent(r)

e <- extent(c(582765, 604290, 1005780, 1047405))

m2r = raster(psf)
extent(m2r) <- e
raster::crs(m2r) <- "EPSG:7767"
``````

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.