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.

  • It seems that you are more looking for inverse distance interpolation. You should extract your village positions and use them as SpatialPointsDataFrame, from which you will be able to do idw on your raster grid. Oct 16, 2017 at 17:37
  • Even if you do not care about 3D interpolation, you can have a look at this question: stackoverflow.com/questions/43240915/… However, you will need to define how you weight your interpolation considering the size of the village. Maybe with the idp? Oct 17, 2017 at 6:17

1 Answer 1


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

  • Yeah I did try that (actually I mention I did that in my question!) but it is not sufficient. Thanks though.
    – tsutsume
    Oct 11, 2017 at 13:22

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.