簡體   English   中英

從多個GPS坐標計算到最近的海岸的距離

[英]Calculating distance to nearest shore from multiple GPS coordinates

我嘗試使用對此問題的回答來解決此問題,但是由於我有許多在全球范圍內分布的坐標,因此無法在我的情況下應用它。

有沒有人可以使用循環來計算一系列點到最近海岸的最小距離(以公里為單位)? 這是我使用的觀點的一個子集(數據此處)

#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

網站分布

看看rgeos

library(rgeos)
gDistance(spPoints, spPolygon, byid = TRUE)

spPoints將是一個保存坐標的SpatialPoints對象。 spPolygon將是具有大陸塊的SpatialPolygons對象。 請參見sp程序包。 確保兩個對象都具有相同的投影並具有合理的投影。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM