[R-sig-Geo] Randomly moving a locality (within set limits)

Frede Aakmann Tøgersen frtog at vestas.com
Mon Aug 25 14:19:10 CEST 2014


Sorry, I didn't really think about what kind of distribution is most suitable for distance. My suggestion of using runif() gives the problem of more points around origin as pointed out my Barry (see attached uniformDistance.png).

However according to the link Barry provided you just need to take the distance as 15 * sqrt(runif(n, 0, 1)). This gives the distribution of the distances as in attached distanceDistribution.png. And the distribution of points is shown in sqrt_uniformDistribution.png.

Also the number of points in 0.05x0.05 cells ( at Equator so the cells have approx. the same area) is like this (formatting will probably not survive through the mail server):

		lons			
	                          (-0.1,-0.05]	(-0.05,0]	(0,0.05] 	(0.05,0.1]
lats	(-0.1,-0.05]	47	42	42	42
	(-0.05,0]	48	52	49	40
	(0,0.05]		51	47	44	41
	(0.05,0.1]	45	37	41	35




Here is the R code for reference:


Ds <- 15
N <- 1000

bears <- runif(N, 0, 360)

lensU <- runif(N, 0, Ds)
sqrtlensU <- sqrt(runif(N, 0, 1))*Ds

png("distanceDistribution.png")
hist(sqrtlensU)
dev.off()

dests00 <- NULL
for (i in 1:N) dests00 <- rbind(dests00, foo(c(0, 0), bears[i], lensU[i]))

png("uniformDistance.png")
xyplot(Latitude ~ Longitude, data = as.data.frame(dests00), aspect = "iso") + 
    xyplot(0 ~ 0, col = "red", pch = 13, cex = 2)
dev.off()

sqrtdests00 <- NULL
for (i in 1:N) sqrtdests00 <- rbind(sqrtdests00, foo(c(0, 0), bears[i], sqrtlensU[i]))

png("sqrt_uniformDistance.png")
xyplot(Latitude ~ Longitude, data = as.data.frame(sqrtdests00), aspect = "iso") + 
    xyplot(0 ~ 0, col = "red", pch = 13, cex = 2)
dev.off()

lats <- cut(sqrtdests00[, "Latitude"], seq(-0.1, 0.1, by = 0.05)) 
lons <- cut(sqrtdests00[, "Longitude"], seq(-0.1, 0.1, by = 0.05)) 
table(lats, lons)

  

Yours sincerely / Med venlig hilsen


Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling

Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
frtog at vestas.com
http://www.vestas.com

Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender. 


> -----Original Message-----
> From: b.rowlingson at gmail.com [mailto:b.rowlingson at gmail.com] On Behalf
> Of Barry Rowlingson
> Sent: 25. august 2014 12:09
> To: Alastair Potts
> Cc: Frede Aakmann Tøgersen; r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] Randomly moving a locality (within set limits)
> 
> On Mon, Aug 25, 2014 at 11:03 AM, Alastair Potts <potts.a at gmail.com>
> wrote:
> > Dear Frede, Barry and Don,
> >
> > Thanks very for your thoughts!
> >
> > Frede's function looks perfect! Thanks very much!!!
> >
> > Barry, would not setting random U(-N,N) distance deal with the uniform
> > distance problem [i.e. distance <- runif(1,-15,15)].
> >
> 
>  No, that would just be the same!
> 
> Its all explained here:
> 
> http://mathworld.wolfram.com/DiskPointPicking.html
> 
> >
> >
> > On 25 August 2014 10:48, Barry Rowlingson
> <b.rowlingson at lancaster.ac.uk>
> > wrote:
> >>
> >> > Now choose
> >> >
> >> > bearing <- runif(1, 0, 360)
> >> >
> >> > and
> >> >
> >> > distance <- runif(1, 0, 15)
> >> >
> >> > Please check the formulas against the homepage above.
> >>
> >>  Note: choosing a random bearing U(0,360) and a random U(0,N) distance
> >>  DOESNT generate a uniform distribution over the disk of radius N!
> >> You get more points near the centre!
> >>
> >>  Barry
> >
> >
> >
> >
> > --
> > Dr. Alastair J. Potts
> > -------------------------------------------------------------------------------------------
> ----------------------
> > NRF Research Career Award Fellow
> > Botany Department, Nelson Mandela Metropolitan University
> > C: 082 491-7275
> > O: 041 504-4375
> > W: https://sites.google.com/site/dralastairpotts/home
> > -------------------------------------------------------------------------------------------
> ----------------------
> > "Research presumes dissatisfaction with existing descriptions of reality
> > and explanations of our experience of it – it rests on the desire to do
> > better than the current consensus. Research, therefore, requires freedom
> to
> > question received wisdom and some background knowledge of why we
> think we
> > know what we think we know." John F. Allen (2003; Future Med. Chem,
> > 2:15-20)
> > -------------------------------------------------------------------------------------------
> ----------------------
> >
-------------- next part --------------
A non-text attachment was scrubbed...
Name: uniformDistance.png
Type: image/png
Size: 9346 bytes
Desc: uniformDistance.png
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20140825/20157040/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: distanceDistribution.png
Type: image/png
Size: 3795 bytes
Desc: distanceDistribution.png
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20140825/20157040/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sqrt_uniformDistance.png
Type: image/png
Size: 10248 bytes
Desc: sqrt_uniformDistance.png
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20140825/20157040/attachment-0002.png>


More information about the R-sig-Geo mailing list