给定纬度较长的原点,开口角度和距离

时间:2016-10-03 20:35:56

标签: r polygon geospatial

想象一下,你有一个苹果派,你从馅饼切了一片。饼图的中心相当于我的原点lat长坐标。从原点到饼干边缘的距离是我的距离,我的开角/方位角是饼图的宽度。

我希望计算饼图圆周上的坐标,因为我有一个原点lat长坐标,从原点到结尾的距离和一个开角/方位角,我猜这可能是半径。我有原点所以这是我的初始点,我希望沿着苹果切片的周长计算7个点,然后我可以再次使用我的原点关闭多边形。

到目前为止,我已编译了以下代码,但我不确定它的效率是多少以及当我需要计算大约9000个苹果派切片的坐标时它是否合适。是否有可以简化此计算的函数?

我有这个工作,但我现在在传单部分的'%>%'中有一个错误,我无法弄清楚。

任何指针(借口双关语)都会受到热烈欢迎。

library(geosphere)
library(leaflet)
N <- 3L;
siteCoor <- matrix(c(152.707480, -27.702700),ncol=2L);
azimuth <- matrix(c(0, 120, 240), nrow = 1) # azimuths for each of the sectors
beamwidth <- c(65) # beamwidth of the antenna
lowerEdge <- azimuth - (beamwidth / 2) # left most bearing of the main beam
increment <- beamwidth/6 # number of degrees to incremet to the next point in the azimuth, always six points
endpoints <- matrix(c(0:6),nrow = 1) # no of points in the sector to calculate the endpoint coordinates for 
sectorAzimuths <- endpoints * increment
siteEndPoints <- apply(lowerEdge, MARGIN =  2, FUN = '+', y = sectorAzimuths) #takes the lowerEdge array and adds these values to sectorAzimuths
polygonCoor <- destPoint(siteCoor, siteEndPoints,2465)
res <- matrix(siteCoor,nrow(polygonCoor)+nrow(polygonCoor)%/%7L*2L*nrow(siteCoor),2L,byrow = T);res[rep(c(F,T,F),c(nrow(siteCoor),7L,nrow(siteCoor))),] <- polygonCoor;
m <- leaflet() %>%
  addTiles() %>%
  addPolygons(lng=res[,1],lat=res[,2], color = "#03F", opacity = 0.9, fill = FALSE)
m

0 个答案:

没有答案
相关问题