wolfsatthedoor
wolfsatthedoor

Reputation: 7313

Using Akima package linear interpolation: interp for a very irregular grid

I have the below grid with a function evaluated only at the points:

I am having trouble setting up the data x,y, and z so I can use

interp(x,y,z)

Does anyone know if this is even possible? Akima says it supports irregular spaced grid.

Data:

categoryvector=21
ninterp=4
points = seq(0,categoryvector,by=ceil(((categoryvector - 0)/(ninterp - 1))))
if(!categoryvector%in%points){points=c(points,categoryvector)}
if(!1%in%points){points=c(points,1); points=sort(points)}
keepers = data.table(expand.grid(prod1vint1=points,prod1vint2=points))
points1 = c(keepers$prod1vint1,0:categoryvector,rep(0,categoryvector+1),rep(categoryvector,categoryvector+1),0:categoryvector)
points2 = c(keepers$prod1vint2,rep(0,categoryvector+1),0:categoryvector,0:categoryvector,rep(categoryvector,categoryvector+1))

z =data.table(points1=points1,points2=points2,z=rnorm(length(points2),10,3))

Making the grid: enter image description here

Upvotes: 0

Views: 745

Answers (1)

Dan
Dan

Reputation: 12084

I think you're looking for interpp not interp.

Upvotes: 1

Related Questions