I have 2 SpatialPointsDataFrame files. I compute the Delaunay Triangles from the first shapefile (shp1
) as in the code below. Then I wish to assign each point from my second shapefile (shp2
) to one of the Delaunay Triangles held within the object vtess.
vtess <- deldir(shp1$coords.x1,shp1$coords.x2)
I can assign each shp2
point to a tessellation tile in the following way:
tl <- tile.list(vtess)
shp2$tile <- 99
for (i in 1:length(shp2$tile)){
shp2$tile[i] <- which.tile(shp2$coords.x1[i], shp2$coords.x2[i], tl)
}
However, while I can find the list of triangles using triang.list(vtess)
, there is no which.triang
command, so it is not possible to similarly assign shp2
points to triangles.
I'm guessing I therefore need to (1) create a SpatialPolygon of the triangles, and then (2) overlap the shp2
points to the new polygon file. Is this the most efficient way? And if so, how do I create a polygon shapefile from the triangles held within vtess
?
Cross-posted, with no reply, here: https://stackoverflow.com/questions/51700872/match-spatialpoints-to-delaunay-triangles