[R-sig-Geo] converting hierarchical clusters to polygons
Bannar-Martin, Katherine
K@therine@B@nn@r-M@rtin @ending from dfo-mpo@gc@c@
Sun May 27 20:58:24 CEST 2018
I have used hierarchical clustering to assign lats and longs (start and end positions of lines) to separate cluster IDs.
I now need to convert each cluster of points to a polygon.
My first attempt was with CHULL, with the aim to then convert each convex polygon to a polygon layer. However, I cannot get the hulls to plot by cluster and then save as an external object.
I think the easiest method would be to take the outside points of each cluster of points and connect them with a polyline and then convert it to a polygon.
I have 100s of clusters per year (13 years) so I do not want to have 1000s of separate polygon files, but instead one layer with all the polygons per year.
Dummy data to show approximate structure:
GISID x y Attribute Year CLUSTER_ID
1 -129.24 52.994 Start 2005 1
2 -131.26 52.73 Start 2006 33
3 -126.02 49.297 End 2005 5
...
Any advice, helpfiles, or vignettes would be greatly appreciated. I've read a variety of stackoverflow entries and r-sig-geo entries and have unsuccessfully adapted other solutions.
e.g. https://stackoverflow.com/questions/44928507/draw-polygons-around-clusters-from-hclust
https://www.nceas.ucsb.edu/scicomp/usecases/GenerateConvexHullAndROIForPoints
Thanks!
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list