[R-sig-Geo] [R] [ESRI-L] outline polygons of point clumps
Roger.Bivand at nhh.no
Fri May 12 20:53:35 CEST 2006
On Fri, 12 May 2006, Xiaohua Dai wrote:
> Sorry, I did not make my question clear. Since I have a point theme
> with many points, some of them may clump together. the problems here
A more specific follow-up after my reply directly to R-help.
I'm assuming you have a running R, and that convex hulls are what you
Take a random data set:
xy <- matrix(runif(500, 0, 10), ncol=2)
xy_clusts <- hclust(dist(xy), method="complete")
# complete linkage hierarchical clustering
# shows the clustering tree
cl_10 <- cutree(xy_clusts, 10)
cl_20 <- cutree(xy_clusts, 20)
cl_30 <- cutree(xy_clusts, 30)
# cut the tree - the objects contain the memberships
which_cl_10 <- tapply(1:nrow(xy), cl_10, function(i) xy[i,])
chulls_cl_10 <- lapply(which_cl_10, function(x) x[chull(x),])
# construct convex hull polygons for each cluster
res <- lapply(chulls_cl_10, polygon)
# and repeat for cl_20 and cl_30
which_cl_20 <- tapply(1:nrow(xy), cl_20, function(i) xy[i,])
chulls_cl_20 <- lapply(which_cl_20, function(x) x[chull(x),])
res <- lapply(chulls_cl_20, polygon)
which_cl_30 <- tapply(1:nrow(xy), cl_30, function(i) xy[i,])
chulls_cl_30 <- lapply(which_cl_30, function(x) x[chull(x),])
res <- lapply(chulls_cl_30, polygon)
If you need the list of convex hulls out as a shapefile, we can do that,
if you need a raster, I'd suggest using kernel density with different
bandwidths for a start, and NA out the densities below a chosen threshold.
Hope this helps,
PS. Use package maptools, function readShapePoints() to read your
shapefile, and coordinates() of the input object to extract the
coordinates. If need be, project from geographical coordinates using
transform methods in package rgdal.
> 1. how to find clumps in a point theme?
> 2. the convex-hull extension I found only deal with all the points in
> a theme at each time? how to make each convex hull around each point
> clump automatically?
> On 5/12/06, Bob Booth <bbooth at esri.com> wrote:
> > Xiaohua,
> > That would be one way to do it. There are others.
> > Try searching ArcScripts for "convex hull"
> > http://arcscripts.esri.com/
> > For example:
> > http://arcscripts.esri.com/details.asp?dbid=14535
> > or
> > http://arcscripts.esri.com/details.asp?dbid=12084
> > Bob
> > -----Original Message-----
> > From: ESRI-L [mailto:ESRI-L at esri.com] On Behalf Of Xiaohua Dai
> > Sent: Friday, May 12, 2006 2:33 AM
> > To: ESRI-L at esri.com
> > Subject: [ESRI-L] outline polygons of point clumps
> > Dear all,
> > How to generate one outline polygon for each point clump? Are there
> > any present functions in ArcView, ArcGIS, R or some freewares? I just
> > had a quick look at the package adehabitat and did not find the
> > function.
> > To my knowledge, I could do it as follows: 1) make a grid map of my
> > study area with cell values = 0; 2) assign 1 to the cells containing
> > at least one point; 3) convert the 1-value cells into polygons.
> > Am I right?
> > Thanks
> > Xiaohua
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo