I have 2D design containing some rectangles, and I have the coordinates of the boundaries of those rectangles. I'm first calculating the wall-to-wall distance between these boundaries, given by nn_dist in the dataset, and then plotting these boundary points as a heatmap, where the color represents the nn_dist value of each boundary point.
Here is the code to plot that (see here for how nn_dist is calculated).
ggplot(dt, aes(x=Y, y=X, z=wall_to_wall_dist)) +
stat_summary_hex(fun=min, bins=500)+
#geom_raster(aes(fill = wall_to_wall_dist), interpolate = TRUE)+
#geom_tile()+
xlim(c(0,10000))+
ylim(c(0,3800))+
scale_fill_gradientn(colors = myPalette, limits = c(100,300))+
theme_default(s_aspectRatio=3800/10000, text_font_size = fontSize)
Here a section from the output:
However, as you can see, most of the plot look empty and it is hard get any intuition from this plot about the wall-to-wall distance information between the rectangles. As a result, I want to fill the empty space between the boundaries in a way that it is interpolated from the color of the boundary points.
How can I do this? In the end the output should, sort of, look like
Here is a tiny part of the dataset (~100,000 rows) that I'm using:
structure(list(ID = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), X = c(318L, 317L, 316L,
315L, 314L, 313L, 312L, 311L, 310L, 309L, 1273L, 1272L, 1271L,
1270L, 1269L, 1268L, 1267L, 1266L, 1265L, 1264L), Y = c(1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L), t = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1), uid = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 1271L, 1272L, 1273L, 1274L, 1275L, 1276L, 1277L, 1278L,
1279L, 1280L), nnX = c(1264L, 1264L, 1264L, 1264L, 1264L, 1264L,
1264L, 1264L, 1264L, 1264L, 318L, 318L, 318L, 318L, 318L, 318L,
318L, 318L, 318L, 318L), nnY = c(10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L),
wall_to_wall_dist = c(946.042810870629, 947.033790315847,
948.025843529595, 949.018967144493, 950.013157803617, 951.008412160481,
952.004726879021, 953.002098633576, 954.000524108871, 955,
955, 954.000524108871, 953.002098633576, 952.004726879021,
951.008412160481, 950.013157803617, 949.018967144493, 948.025843529595,
947.033790315847, 946.042810870629)), row.names = c(NA, -20L
), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x7fce30813ce0>)
X,Yrepresent the location of the boundary pointsnnX, nnYrepresent the nearest neighbour boundary point that is not on the same rectangle, seenn_distis the distance betweenX,YandnnX, nnYIDa unique id for each rectangleuida unique id for each boundary point, regardless of the rectangle they are on


