# [R-sig-Geo] spsample

Tom Philippi tephilippi at gmail.com
Fri Jul 10 19:23:19 CEST 2015

```If you're really sampling (continuous) points in a circle, you can do what
you want by sampling in polar coordinates, then converting to Cartesian if
necessary.  You presumably want uniform direction (2*pi*runif()).  If your
overall circle has radius R, if you draw radius r from a pdf prob ~ r^2 you
get uniform area probability.  If you make that some function less steep
than r^2 you will have greater sample intensity closer to the center.

That is a very general approach, because you did not specify how much more
likely you want points to be near the center.

I hope that this helps...

Tom 2

On Fri, Jul 10, 2015 at 8:23 AM, MacQueen, Don <macqueen1 at llnl.gov> wrote:

> I'm not so deeply familiar with spsample that I know of a way to do this
> directly.
>
> However, I think it would be pretty easy to use spsample to first obtain
> more points than needed, then calculate all the distances from the center,
> then use the base::sample function to select a weighted sample, with
> weights based on the distance from the center (see the prob argument to
> sample).
>
> -Don
>
>
> --
> Don MacQueen
>
> Lawrence Livermore National Laboratory
> 7000 East Ave., L-627
> Livermore, CA 94550
> 925-423-1062
>
>
>
>
>
> On 7/10/15, 2:59 AM, "R-sig-Geo on behalf of Luca Candeloro"
> <r-sig-geo-bounces at r-project.org on behalf of luca.candeloro at gmail.com>
> wrote:
>
> >Hi,
> >following the example found in SpeciesDistributionModelling, a given
> >number
> >of points is drawn randomly within a circle:
> >
> >x <- circles(pts, d=50000, lonlat=T, col='light gray')
> ># sample randomly from all circles
> >> samp1 <- spsample(x at polygons, 250, type='random', iter=25)
> >
> >Is there a way to specify weigths decreasing from the circle center, so
> >that random points are most likely near it?
> >
> >thanks ,
> >Luca
> >
> >       [[alternative HTML version deleted]]
> >
> >_______________________________________________
> >R-sig-Geo mailing list
> >R-sig-Geo at r-project.org
> >https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

[[alternative HTML version deleted]]

```