[GIS] Spatial interpolation from categorical data in R

interpolationkernel densityrraster

I have a spatial point data set, where each point represents a person pronouncing a word in a specific fashion. Let's say I have six different pronunciations.

In an earlier iteration, I aggregated the point data to a hexagonal grid, the color represents the dominant pronunciation in the hexagon while the opacity represents its dominance, see: https://www.srf.ch/static/srf-data/data/2016/dialektkarten-karte/

Now I'd like to spatially interpolate the data to get a continuous surface, similar as Josh Katz did: http://www4.ncsu.edu/~jakatz2/files/dialectposter.png

enter image description here

He uses something he calls "k-nearest neighbor kernel smoothing" but he's not publishing his R code so I don't fully understand how that is supposed to work with categorical data. I perfectly understand on how to do it with continuous variables, but not with the latter.

The pseudo-algorithm I came up with so far:

  • Repeat the "final estimate" formula for each pronunciation, using yi = 1 for points where that pronunciation is used, yi = 0 if not. By doing so, you get a grid for each pronunciation. The cells represent the probabilities of the respective pronunciation appearing at that grid cell.
  • Now, find the most probable pronunciation in each grid cell. This determines the cell color (hue). Its probability determines the color value (i.e.: the higher, the darker, and vice versa).
  • Find a way to map that resulting grid / raster – might be tricky because it contains two variables that need to be mapped to visual variables (dominant pronunciation and its probability).

But maybe this is completely off – and also, I wonder whether there are R packages for spatial interpolation of categorical data. So far I have only found knn methods and the like and I suppose I have to build something myself.

Best Answer

In the end, I figured out a method with the kknn package. If somebody is still interested in this answer, I recommend reading my blog post on the topic.

Related Question