I am trying to plot a data with (Lat, Lon) and a value in each location. What I need to do is to plot the data over a shapefile, represent each value with a different color, and smooth the values, so no gaps occur in the map.

The data has the following structure: (Longitude, Latitude, Value), could you help me please.

I know how to plot the data over a shapefile with a different color, but the issue is in smoothing the values.

The data for the question is available in the following link:


where the:

1- (Lon, Lat, Value) data is in csv file "cluster__groups"

2- The shapefile files are in the folder "shapefile_question"

I need to show them in regions. The output should be something similar to the following image: [output_result

I tried to solve and search for a solution but could not find a solution.


I will post a solution with some guidance, since there was no code posted. It seems that what you are after is how to perform spatial interpolation with R. You have your points divided into n categories and you want to create regions out of them. For this, there are a number of different approaches, and I will list three of them, easiest to hardest:

  1. Nearest neighbour;
  2. Inverse Distance Weighting (IDW);
  3. Kriging.

All of these techniques are available in R, and you can find a nice set of examples here. Keep in mind that these three techniques will give you slightly different regions, and sometimes they are combined in order to produce an "ensemble" of the most likely surfaces.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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