【发布时间】:2015-10-15 15:32:51
【问题描述】:
我已尝试使用对this question 的响应来解决此问题,但我无法在我的情况下应用它,因为我有许多分布在全球范围内的坐标。
有没有人可以使用循环计算从一系列点到最近海岸的最小距离(公里)?这是我正在使用的点的子集(DATA HERE)
#setwd and load directories----
setwd("your_wd")
require (ggplot2)
require (ggmap)
#build a map to plot distribution of sample sites ----
sites<-read.csv("sites.csv", header=T)
#Using GGPLOT, plot the Base World Map
mp <- NULL
mapWorld <- borders("world", colour="gray50", fill="gray50") # create a layer of borders
mp <- ggplot() + mapWorld
#Now Layer the sites on top
Lon<-sites$x
Lat<-sites$y
mp <- mp+ geom_point(aes(x=Lon, y=Lat),color="blue", size=3)
mp
【问题讨论】:
标签: r loops dictionary polygon distance