[GIS] Continuous smoothing of raster using R

graphicsrrastersmoothingweighted-overlay

I have a dataset on some villages like this on a grid:

village raster

I want to fill the space of the whole grid so that each grid cell has a value that reflects the pressure from the surrounding villages (i.e., the value would be something like average distance to all villages, weighted by the size of each village).

As a first attempt, I tried to smooth it with:

    villageRaster <- focal(villageRaster, w=matrix(1, 9, 9), mean)

to give:

smooth village raster

But there are still large white areas with no values.

Can someone suggest a nice way to smooth across the whole space?

I am using R for this preferably.

Best Answer

You could look into this approach as suggested Smoothing raster map using R?:

Here are some ideas.

With base plot you can do

 plot(x, interpolate=TRUE)

You can also resample your data using disaggregate (x, 5, method='bilinear')

 y <- disaggregate x, 5, method='bilinear')

Or indeed smooth it using a focal operation

 y <- focal(x, w=matrix(1, 5, 5), mean)

Or a combination

 y <- disaggregate(x, 5)
 y <- focal(y, w=matrix(1, 5, 5), mean)

The question whether doing this is a good idea or not is another matter, that I'll leave to you to decide