r - Drawing a Circle with a Radius of a Defined Distance in a Map -


i able plot map , caption specific point:

library(maps) map("state") text(-80.83,35.19,"charlotte",cex=.6) 

i can plot circle centered around point:

symbols(-80.83,35.19,circles=2, add=true) 

however, control size of circle. in particular, want draw circle radius of 100 mile around multiple locations contained in data.frame, matrix, or list.

you can write function customize how want circle look. example:

plotcircle <- function(x, y, r) {   angles <- seq(0,2*pi,length.out=360)   lines(r*cos(angles)+x,r*sin(angles)+y) } 

then if had set of coordinates in data frame:

coords <- data.frame(x = c(-1,0,1), y = c(-1, 0.5, 1)) 

you can start initial plot (map, or empty plot, etc)

plot(1,type='n',xlim=c(-2,2),ylim=c(-2,2)) 

then call plotting function on list of coordinates:

apply(coords,1,function(df) plotcircle(df[1],df[2],.3)) 

Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -