The task is to downsample (aggregate) a raster from 100m pixel size to 460m. The aggregation should be performed using a Gaussian filter. To better understand the task, I am following the paper ‘The effect of the point spread function on downscaling continua’. Most of the paper is irrelevant to my task, all I care from this paper is this one step:
(Note: by upscaling the authors mean aggregation)
One of the authors is my supervisor and I asked him if I can blur my fine resolution raster and then aggregate it using a common interpolation algorithm (nearest neighbor, bilinear etc). This is not the way to go. The aggregation should be done using a Gaussian kernel filter (the point spread function is assumed to be Gaussian). Also, If I blur and then resample is like I add extra PSF effect apart from what my image already has.
There is a post on Reddit, where a person suggests (without sharing how to do it) that this a common computer vision task. I share his suggestion:
My supervisor told me that the way I should create the aggregated raster is by applying a gaussian kernel filter to the fine data, but with a very large width. This large width I think it determines the output pixel size (which as I said I want it to be 460m).I say that based on this post.
According to my supervisor: For each new coarse pixel go to its center and calculate the weights (from the PSF) needed for each fine pixel surrounding it (PSF = point spread function = Gaussian filter).
You can download my data from here, or if you use R
:
fr = rast(ncols=108, nrows=203, nlyrs=1, xmin=583400, xmax=594200, ymin=1005700, ymax=1026000, names=c('B10_median'), crs='EPSG:7767') # fine resolution raster
cr = rast(ncols=23, nrows=43, nlyrs=1, xmin=583280, xmax=593860, ymin=1006020, ymax=1025800, names=c('coarse_image'), crs='EPSG:7767') # template (coarse) resolution raster
I shared a template raster because I want my aggregated raster to match the resolution (ncols and nrows) of a coarse resolution raster that I will use later in my analysis.
Lastly, the units of σ (sigma) and the Gaussian should be in pixels.
Any recommendations on how to proceed? Preferably in R
but it doesn’t really matter.
OpenImageR
...down_sample_image
". Provide a link, please -- those of us who don't know R but do know image processing can interpret this for you -- with a link. $\endgroup$