# Algorithm to find the boundary grid points [duplicate]

Let us consider a set S consisting of a collection of grid locations (i,j),i,j=1,\ldots,n, in 2-dimensional gridded plane. Here the point (i,j) corresponds to a rectangular grid in the X-Y plane.

This set has the property that one can reach any element (i,j)\in S from any other element ({i'},{j'})\in S through a series of neighbouring grid points which are also in S.

I am interested about the shape of the set S in the plane, for this reason I need the boundary grid locations of the set S. Note: R-code

data=read.csv(file="trial.csv")

require('ggplot2')

pred.points <- ggplot(data = data,
aes(x = lat,
y = lon,
colour = variable)) +
geom_point()

print(pred.points)


I need an algorithm to find the boundary grid locations for the set?

Here I don't know whether the set is concave or convex.

• Can you add an image illustrating your issue? – SS_Rebelious Nov 5 '14 at 8:31
• So your primary tool is R? Consider adding your code then so we could understand what exactly have been plotted here. – SS_Rebelious Nov 5 '14 at 10:42
• Yes I used R. I edited the figure and added the R-code. – Janak Nov 5 '14 at 11:26
• You might want to look into alpha hulls. There exists an R implementation in alphahull::ashape. – whuber Nov 5 '14 at 19:29
• Thank you for letting us know. To help connect future readers to an answer, I will close this as a duplicate of a question whose answers include the R solution (along with solutions on other platforms). – whuber Nov 8 '14 at 16:57