Bjørn Økland
2012-Feb-03 14:59 UTC
[R] SPATIAL QUESTION: HOW TO MAKE POLYGONS AROUND CLUSTERS OF POINTS AND EXTRACT AREAS AND COORDINATES OF THESE POLYGONS?
Imagine that I have a large number of points (given by coordinates x and y) that vary in density per space. For the purpose of demonstration it could be generated like this: s <- data.frame(x=runif(10000,0,900),y=runif(10000,0,900)); plot(s) I want to create polygons around the points where point density is greater than a selected threshold (for example, by using krieging or equivalent method). For these polygons, I want to have the centre coordinates and the size of the area for further use in analyses. I would be very grateful if I could be shown the R packages and functions I should use to accomplish this, and even some outline of the code. Is it possible? Best regards Bjørn [[alternative HTML version deleted]]
MacQueen, Don
2012-Feb-04 00:40 UTC
[R] SPATIAL QUESTION: HOW TO MAKE POLYGONS AROUND CLUSTERS OF POINTS AND EXTRACT AREAS AND COORDINATES OF THESE POLYGONS?
I would suggest asking this question on r-sig-geo. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 2/3/12 6:59 AM, "Bj?rn ?kland" <okb at skogoglandskap.no> wrote:>Imagine that I have a large number of points (given by coordinates x and >y) that vary in density per space. For the purpose of demonstration it >could be generated like this: s <- >data.frame(x=runif(10000,0,900),y=runif(10000,0,900)); plot(s) > >I want to create polygons around the points where point density is >greater than a selected threshold (for example, by using krieging or >equivalent method). For these polygons, I want to have the centre >coordinates and the size of the area for further use in analyses. > >I would be very grateful if I could be shown the R packages and functions >I should use to accomplish this, and even some outline of the code. Is it >possible? > >Best regards >Bj?rn > > > [[alternative HTML version deleted]] >
Rolf Turner
2012-Feb-06 23:51 UTC
[R] SPATIAL QUESTION: HOW TO MAKE POLYGONS AROUND CLUSTERS OF POINTS AND EXTRACT AREAS AND COORDINATES OF THESE POLYGONS?
On 04/02/12 03:59, Bj?rn ?kland wrote:> Imagine that I have a large number of points (given by coordinates x and y) that vary in density per space. For the purpose of demonstration it could be generated like this: s<- data.frame(x=runif(10000,0,900),y=runif(10000,0,900)); plot(s) > > I want to create polygons around the points where point density is greater than a selected threshold (for example, by using krieging or equivalent method). For these polygons, I want to have the centre coordinates and the size of the area for further use in analyses. > > I would be very grateful if I could be shown the R packages and functions I should use to accomplish this, and even some outline of the code. Is it possible?You can do this using the spatstat package. E.g.: require(spatstat) set.seed(42) X <- rpoisspp(100) Y <- density(X) Z <- levelset(Y,130,">") U <- connected(Z) V <- tiles(tess(image=U)) lapply(V,centroid.owin) lapply(V,area.owin) You should read the help on the functions invoked above. It might be illuminating to do some plotting along the way (of X, Y, Z, U, and V). cheers, Rolf Turner
Rolf Turner
2012-Feb-07 03:06 UTC
[R] SPATIAL QUESTION: HOW TO MAKE POLYGONS AROUND CLUSTERS OF POINTS AND EXTRACT AREAS AND COORDINATES OF THESE POLYGONS?
It has been pointed out to me (in a private email) that there was a typo in my previous post; X <- rpoisspp(100) should read X <- rpoispp(100) (i.e. just one "s"). Sorry 'bout that! :-) cheers, Rolf
Seemingly Similar Threads
- Filling polygons with points
- extracting coordinates from SpatialPolygonsDataFrame using slot functions
- basic spatial query
- Spatstat - coordinates in observation window
- How do I ensure that the polygon in spatstat::owin(poly=<polygon>) does not have “negative area”