I'm trying to draw some circles and I was sort of hoping they would intersect with some points, alas...
library(maptools)
library(plotrix)
xy <- matrix(runif(20, min = -100, max = 100), ncol = 2)
distance <- spDistsN1(xy, xy[1, ])
plot(0,0, xlim = c(-100, 100), ylim = c(-100, 100), type = "n")
points(data.frame(xy))
points(xy[1, 1], xy[1, 2], pch = 16)
draw.circle(xy[1, 1], xy[1, 2], radius = distance)
The above code does the following:
According to the distance formula, this is √(x−0)2+(y−0)2=√x2+y2. A point (x,y) is at a distance r from the origin if and only if √x2+y2=r, or, if we square both sides: x2+y2=r2. This is the equation of the circle of radius r centered at the origin.
Click (click, don't drag) on the map at the center point of your circle (eg: Vancouver) Move your mouse until the circle radius is the distance you want (eg: 750km) Click the map again to complete the circle. In the Ruler window, click the "Save" button.
The length between two points around the circumference of a circle is an arc.
This is the old aspect ratio problem that comes up from time to time when people are drawing ellipses, circles, etc.
Substituting MASS::eqscplot
for plot
(edit: or using asp=1
: see ?par
) appears to solve the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With