[R-sig-Geo] Spatial points to lines/polygons

Gustaf Granath gustaf.granath at gmail.com
Mon Feb 11 23:59:28 CET 2013


Hi,
I have mapped structures with a GPS (walked along their edges) and Im 
now trying to make polygons from my coordinates. The GPS data are a bit 
fuzzy and I want to establish the edge of the structure with a smoother 
or similar. However, I have not been able to find an easy way to do this 
in R. This seems odd to me and I might have missed something. I have so 
far tried doing lines with spline (xspline) or polygons with the 
alphahull package, but they are tricky to work with (usually overfit).   
Any pointers are welcome.

Gustaf


Example code, testing the alphahull package:
require(alphahull)
set.seed(1)
xx <-c(1:10,8,5,2)
xx <- xx + rnorm(39,0,0.4)
yy <-c(1:5,5:1,1,1,1)
yy <-yy + rnorm(39,0,0.4)
plot( xx ~ yy)
xy <-data.frame("x" = xx, "y" = yy)
coords <- coordinates(xy)

# alpha-shape
x.as <- ashape(coords, alpha=5)

# alpha-hull
x.ah <- ahull(coords, alpha=5)

#plot
plot(x.as)
plot(x.ah)

-- 
Gustaf Granath (PhD)
Post doc
McMaster University
Email: gustaf.granath at gmail.com



More information about the R-sig-Geo mailing list