[R-sig-Geo] point process spatial sampling
Roger Bivand
Roger.Bivand at nhh.no
Mon Jun 19 11:20:02 CEST 2006
On Sat, 17 Jun 2006, zhijie zhang wrote:
(This is the offline description of the underlying research problem,
posted with permission from the questioner):
I'm not sure that the steps suggested below are adequate, and input from
field ecologists with experience in choosing sampling frameworks will be
very welcome. My understanding is that the officially stipulated 0.11 m2
observations are felt by the questioner to be "missing" the snails at
certain levels of clustering or regularity, but the suggestion below just
gives a framework for simulating distributions from regular to clustered,
so that the appropriateness of the officially stipulated sampling scheme
can be examined (corrections please, I'm not sure that this is a good
representation of the problem).
> Dear prof. Roger Bivand,
> Thanks very much ! I'd like to give you some hint that why i want to do
> that. I'm studying somthing on Oncomelania Hupensis(a kind of snail),
> and our survey method in our country is systematic sampling and the
> sample is 0.11m2square, which is a national criteria and has no
> theoretical support.
> Recently, i find that Oncomelania Hupensis is clustered in certain
> density, and regular in other density. R is a good software for spatial
> statistics in my opinion, so i want to do some simulations. That is,
> selecting a square or rectangular, then divide it into a number of
> 0.11m2 square/grids(0.33m*0.33m),assign some values from
> cluster/regular/random process to the 0.11m grids, finally sample from
> it and compare the samples with the population through some indices(e.g.
> density of snail) to see which sampling method is the best.
>
> > *step1*: Generate a planar x(0,100)*y(0,100) ;
>
> This is a 0,100 by 0,100 square, right*?---square or maybe a rectangular
> *
> > *step2*: Divide the planar into 100 grids,either use the number of grids
> or
> > use the coordinates of x/y;(like gridpts(poly,npts,xs,ys)
> > #gridpts(splancs),)
library(spspatstat)
# rSpatial <- "http://r-spatial.sourceforge.net/R"
# install.packages("spspatstat", repos=rSpatial)
edge <- 10/3
nc <- 10
edge_nc <- edge/nc
edge_nc^2
crds <- matrix(c(0,0,0,edge,edge,edge,edge,0,0,0), ncol=2, byrow=TRUE)
SPoly <- SpatialPolygons(list(Polygons(list(Polygon(crds)), ID=1)))
SPowin <- as(SPoly, "owin")
grd <- GridTopology(c(edge_nc/2, edge_nc/2), c(edge_nc, edge_nc), c(nc, nc))
SG <- SpatialGrid(grd)
ng <- prod(slot(grd, "cells.dim"))
pp <- rMatClust(1, 0.3, 5, win=SPowin)
# ^^^^
# the cluster radius argument can be manipulated to go from tight
# clusters to CSR, but the number of points is seldom kappa per unit area
# * mu
# pp <- rSSI(0.3, 50, win=SPowin)
# provides from CSR to regular by manipulating the first argument,
# the inhibition distance, but here you know how many points are required
while (length(pp$x) != 50) pp <- rMatClust(1, 0.3, 5, win=SPowin)
# for want of another way of getting exactly 50 points - maybe thinning
# would be OK? Especially as hitting a larger number will be tricky?
SP_MC03 <- as(pp, "SpatialPoints")
where <- overlay(SG, SP_MC03)
counts <- table(where)
res <- rep(0, ng)
res[as.integer(names(counts))] <- counts
SGDF <- SpatialGridDataFrame(grd, data=AttributeList(list(MC03=res)))
# from here on, add the new point patterns as counts to SGDF by adding
# columns, for example:
pp <- rSSI(0.3, 50, win=SPowin)
SP_SSI03 <- as(pp, "SpatialPoints")
where <- overlay(SG, SP_SSI03)
counts <- table(where)
res <- rep(0, ng)
res[as.integer(names(counts))] <- counts
SGDF$SSI03 <- res
image(SGDF, "MC03")
plot(SP_MC03, add=TRUE)
image(SGDF, "SSI03")
plot(SP_SSI03, add=TRUE)
The spatstat package provides a wide range of ways of simulating random
point patterns, and it is very possible that the overlay() method in the
sp package used here for binning and then counting the points in your
framework could be replaced by a function from spatstat.
Hope this helps,
Roger
(with thanks to Paulo Ribeiro, who helped talk me though this in Vienna
after the successful useR 2006 meeting - all mistakes are my own fault!)
>
> How many grid cells do you need, 100 or 100 by 100?, that is npts=100 or
> xs=100,ys=100?--*if possible, i'd like the the area of grid is 0.11m2 ;if
> it's difficult, then use xs=100,ys=100.*
>
> > *step3*: generate the spatial points with autocorrelation, and link points
> > with the grid center;
>
> Are the points from a point process model, in which case do you want
> clustered or regular? And if so, do you want to assign them to the grid
> cells (I think so)?--i*'d like the generate three different kind of
> data,that is clustered, regular and random point process and then assign
> them to the grid cells. That is to say, to do three kind of simulations. *
>
> *Finally*, to sample from the grids through systematic, random and
> stratified sampling.
> I hope that i have explained my ideas clearly, thank very much for your
> help!
>
>
>
>
>
> 2006/6/17, Roger Bivand <Roger.Bivand at nhh.no>:
> >
> > On Fri, 16 Jun 2006, zhijie zhang wrote:
> >
> > > Dear friends,
> > > I want to finish the following task, hope someone to give the R
> > > programs,thanks.
> >
> > Could I ask for a little clarification?
> >
> > >
> > > *step1*: Generate a planar x(0,100)*y(0,100) ;
> >
> > This is a 0,100 by 0,100 square, right?
> >
> > > *step2*: Divide the planar into 100 grids,either use the number of grids
> > or
> > > use the coordinates of x/y;(like gridpts(poly,npts,xs,ys)
> > > #gridpts(splancs),)
> >
> > How many grid cells do you need, 100 or 100 by 100?, that is npts=100 or
> > xs=100,ys=100?
> >
> > > *step3*: generate the spatial points with autocorrelation, and link
> > points
> > > with the grid center;
> >
> > Are the points from a point process model, in which case do you want
> > clustered or regular? And if so, do you want to assign them to the grid
> > cells (I think so)?
> >
> > Roger
> >
> > > how to do that ? Because of poor R programing techniques, I hope
> > someone
> > > will spend a few minutes to help me.
> > > Any suggestions are greately welcome!
> > > Hope to get the programs as soon as possible.
> > >
> > > With kind regards,
> > > Wei,Chang
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > _______________________________________________
> > > R-sig-Geo mailing list
> > > R-sig-Geo at stat.math.ethz.ch
> > > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> > >
> >
> > --
> > Roger Bivand
> > 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
> >
> >
>
--
Roger Bivand
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
mailing list