[R-sig-Geo] spsample: random points within a radius r from observed locations

Rafael Wüest rafael.wueest at gmail.com
Tue Oct 27 10:28:44 CET 2015


Hi Gabriele

Don't know of such a function, but the following should return 10 random 
locations per polygon in 'buffer'

randompoints.list <- sapply(buffer at polygons, spsample, n = 10, type = 
'random')
randompoints <- do.call(rbind, randompoints.list)

May be a start...

Cheers,
Rafael


On 27.10.15 09:37, Gabriele Cozzi wrote:
> Dear list,
>
> I have a set of relocation data (call it pnts).
>
> What I want to do is to create, for each relocation of pnts, n alternative
> relocations within a radius r.
>
> My intuitive approach was to use of the spsample function in the sp
> package.
>
> buffer <- gBuffer(spgeom = pnts, width=r,  byid=T)
> randompoints <- spsample(x=buffer, n=10, type="random", iter=10)
>
> The problem here is that spsample creates 10 random points over all
> Polygons in the buffer object and not for each Polygon within buffer.
>
> Is there a function that returns random locations by passing a
> SpatialPoints-class object to it and a radius r?
>
> Any help is appreciated.
>
> Gabriele
>
>
>

-- 
Rafael Wüest
rafael.wueest at gmail.com
http://www.rowueest.net



More information about the R-sig-Geo mailing list