[R-sig-Geo] Pruning a delaunay triangulation with a shape

Pierre Roudier pierre.roudier at gmail.com
Thu Jul 22 07:35:01 CEST 2010


Dear researchers,

I'm scratching my head on a problem involving neighbourhood
definition: I am using the Delaunay triangulation to generate a
neighbourhood relationship object on a set of georeferenced points.

I am using the tripack package for that (tri.mesh() for the
triangulation and neighbours() to create the neighbourhood).

However, I would like to prune this neighbourhood using a polygon, so
that some neighbourhood relationships won't be taken into account.
Here's an illustrating example:

dat <- data.frame(
x=c(0.34433527, 0.08592805, 0.55564179, 0.03938242, 0.98044051,
0.19835405, 0.94186612, 0.56208017, 0.31093811, 0.54341230,
0.93508703, 0.38160473, 0.89435383, 0.55457428, 0.22406338),
y=c(0.997803213, 0.094993232, 0.509774611, 0.615526709, 0.004314438,
0.676662461, 0.026060349, 0.165807011, 0.596449068, 0.469553704,
0.888788079, 0.163129754, 0.340335312, 0.621845245, 0.019412254)
)

dat.tr <- tri.mesh(dat)

bound <- data.frame(
x=c(0.34063939, 0.56754974, 0.95361248, 0.96464284, 0.60694389,
0.58173163, 0.58330740, 0.91421832, 1.00403700, 0.96464284,
0.50294332, 0.39263968, 0.22560845, 0.02548613, 0.25397225,
-0.01233226),
y=c(1.02171515, 0.70486571, 0.92207697, 0.84834471, 0.62116963,
0.53747356, 0.47569788, 0.35812482, 0.02134774, -0.07231216,
0.15287015, 0.14489909, -0.03444965, 0.09707276, 0.56138672,
0.58729265)
)

plot(dat)
polygon(bound, col='red')
plot(dat.tr, add=TRUE, col='blue')

In that example, I would like to eliminate all the (blue)
neighbourhood relationships that are not in the red polygon.

Would anybody has a simple way to do this?

Thanks,

Pierre



More information about the R-sig-Geo mailing list