4

I want to resample a raster from 15m to 460m using a Gaussian filter.

The goal

I am having a coarse image which I want to downscale. I also have a fine resolution band to assist the downscaling. The downscaling method I am using is called geographically weighted area-to-point regression Kriging (GWATPRK). The method consists of two steps:

  1. GWR and,
  2. ATPK on the GWR's residuals.

In order to perform GWR using raster data, those needs to have the same pixel size. This means that, my fine resolution image needs to be upscaled to match the spatial resolution of the coarse band. This upscaling of the fine band needs to be done using a Gaussian kernel (i.e., the PSF). I have found that GRASS GIS has a built-in tool within QGIS called r.resamp.filter. Whenever I try to execute the code I am getting this error (this is the log window):

ERROR: At least one filter must be finite
C:\Users\Geography\Documents>g.region raster=outpute19c4df1297e4428bdf5c9a3f38ae890
ERROR: Raster map <outpute19c4df1297e4428bdf5c9a3f38ae890> not found
C:\Users\Geography\Documents>r.out.gdal -t -m input="outpute19c4df1297e4428bdf5c9a3f38ae890" output="C:\Users\Geography\AppData\Local\Temp\processing_uJGZeO\2c592b8c22724aab80f0506e9a4a8192\output.tif" format="GTiff" createopt="TFW=YES,COMPRESS=LZW" --overwrite
ERROR: Raster map or group <outpute19c4df1297e4428bdf5c9a3f38ae890> not found
C:\Users\Geography\Documents>exit
Execution of <C:\Users\Geography\AppData\Local\Temp\processing_uJGZeO\grassdata\grass_batch_job.cmd> finished.
Cleaning up temporary files...
Press any key to continue . . .
Execution completed in 3.22 seconds
Results:
{'output': 'C:\\Users\\Geography\\AppData\\Local\\Temp\\processing_uJGZeO\\2c592b8c22724aab80f0506e9a4a8192\\output.tif'}

Loading resulting layers
The following layers were not correctly generated.
• C:/Users/Geography/AppData/Local/Temp/processing_uJGZeO/2c592b8c22724aab80f0506e9a4a8192/output.tif
You can check the 'Log Messages Panel' in QGIS main window to find more information about the execution of the algorithm.

I tried many parameters but I can't understand what am I doing wrong. Below I attached a screenshot of one of my tries setting the parameters. I also tried to set x_radius and y_radius. What am I missing here?

r.resamp.filter

From here you can download the image.

I am leaving this link, from an other question I found which is exactly what I am trying to achieve.

2
  • I am not sure I understand what you mean when you say you want to "resample a raster from 15m to 460m". Do you want to increase the resolution & keep the same extent as the current raster or do you also want to increase the extent? Commented Sep 2, 2022 at 20:39
  • I want to decrease the spatial resolution of the raster (make the pixel size larger) using a Gaussian filter. The raster has 15m pixel size and I'd like to upscale it to 460m using the method I said.
    – Nikos
    Commented Sep 2, 2022 at 20:52

3 Answers 3

2

I'm not sure why the QGIS Processing module failed, but I think it has to do with chosing the windowing function. Note in the manual page:

"Kernels with infinite extent (Gauss, normal, sinc, Hann, Hamming, Blackman) must be used in conjunction with a finite windowing function (box, Bartlett, Hermite, Lanczos)."

So you probably need to select both Gaussian and Box filtering.

However I think there is some misunderstanding here. A kernel filter resampling method is not intending for upscaling. All the available filters are low pass filters for smoothing the original raster, and typically would maintain the original raster resolution. To resample at a coarser resolution the module r.resamp.stats is the correct tool.

In any case, all the resampling modules in GRASS GIS work at the current computational region. But in QGIS Processings, AFAIK, the computational region is always set to the input raster. I would suggest to run the resamping in GRASS directly. So the workflow, in GRASS (not thru the QGIS Processing Toolbox) would be:

  • Start GRASS in a Location that matches the reference system of the original raster
  • import the original raster (or r.external to point to that raster)
  • Set the region to that raster's extent and resolution
  • then reset the computation region to the desired coarse resolution
  • and now run the resampling.

Since you are upscaling to a much coarser resolution, each final pixel will be calculated from about 900 pixels from the original high resolution raster (460/15 * 460/15). If you still want to use a Gaussian resampling filter while upscaling, then the above steps are still required. You have to set the region to your desired 460 m resolution before running the resamp function. Just note that each new pixel at coarse resolution will be calculated from thousands of pixels in a window surrounding that pixel.

You might try both the r.resamp.stats module and r.resamp.filter and compare the results...

8
  • I quote the paper I am following (The effect of point spread function on downscaling continua, p253 Eq(9)): the coarse image produced by upscaling the corresponding fine band k using a PSF (in my case the PSF is assumed to be Gaussian). This means that the the authors used the Gaussian filter to upscale the image (I also spoke with one of them and he confirmed that)
    – Nikos
    Commented Sep 3, 2022 at 9:25
  • When I use both the Box and the Gaussian filtering I am getting this error: ERROR: Differing number of values for filter= and [xy_]radius=
    – Nikos
    Commented Sep 3, 2022 at 9:35
  • Sorry, but I don't get how that paper is relevant. They address the effect of PSF in downscaling. They degraded an original 2 m resolution image to 4 or 8 m., (or Sentinel 2 from 10 m to 20 m) as a preparatory step in their methodology. Then tested how PSF effects restoration of the image to it's natural resolution. Whereas you are upscaling the original, and working at an order of magnitude more change than that cited work. I would be wary of extrapolating from Wang et al. data preparation as a theoretical base for your approach.
    – Micha
    Commented Sep 3, 2022 at 12:22
  • In addition, the link you provided to an earlier SO post at the end of your question also does not use any Gaussian filter. The answers suggest ways to resize images: no resampling at all.
    – Micha
    Commented Sep 3, 2022 at 12:29
  • I edited my question and made it more specific. I apologize for not doing that from the beginning. All in all, my goal is to downscale an image. Before the downscaling, I need to perform regression using 2 raster. One has large pixel size, the other has small pixel size. In order to perform the regression I need to upscale the fine resolution raster to match the pixel size of the coarse band. This upscaling needs to be done using a Gaussian kernel (i.e., the point spread function which I assume is Gaussian). I hope I made my problem more clear now.
    – Nikos
    Commented Sep 3, 2022 at 12:48
0

Another approach if you want to stay inside QGIS and if you can't get the GRASS module to work would be to change the resolution to the desired cell size with the warp (reproject) algorithm and then apply the gaussian filter afterwards with the SAGA module gaussian filter.

1
  • No because the Gaussian filter is the upscaling. Otherwise it's like I'm blurring the image twice.
    – Nikos
    Commented Sep 3, 2022 at 9:17
0

Based on the comments and answer of @Micha and some answers from the Github, here is how I upscaled the image:

  1. Start GRASS in a Location that matches the reference system of the original raster
  2. import the original raster (or r.external to point to that raster)
  3. Set the region to that raster's extent (g.region)
  4. set the spatial resolution to 460m (g.region)
  5. select the box and gauss boxes in the r.resamp.filter command and the filter radius in the optional tab to 250, 250 The output is ~460m (referring to the pixel size).

I won't accept this post the correct answer as I am still investigating the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.