我將兩個圓和一個多邊形添加到傳單地圖中。這是我繪製這三種形狀的代碼。有什麼辦法可以得到這三種形狀的聯合?傳單中的圓和多邊形聯合
leaflet(options = leafletOptions(minZoom = 0, maxZoom = 18))
m <- leaflet()%>%
addTiles()%>%
setView(72.84320,20.43397,zoom=16)%>%
#Add mouse position
addMouseCoordinates(style = "basic", epsg = NULL,
proj4string = NULL, native.crs = FALSE)
#Runway Extremities
ARP <- c((72 +(50/60)+(32.67/3600)),(20+(26/60)+(1.54/3600)))
ptTop2 <- c((72 +(50/60)+(16.98/3600)),(20+(25/60)+(25.18/3600)))
ptBottom2 <- c((72 +(50/60)+(43.45/3600)),(20+(26/60)+(18.13/3600)))
ptTop1 <- c((72 +(50/60)+(8.64/3600)),(20+(26/60)+(8.08/3600)))
ptBottom1 <- c((72 +(50/60)+(44.21/3600)),(20+(26/60)+(5.63/3600)))
ap1 <- 95
ap2 <- 26
pt1 <- destPoint(ptTop1,ap1+90,4000)
pt2 <- destPoint(ptTop1,ap1-90,4000)
pt3 <- destPoint(ptBottom1,ap1-90,4000)
pt4 <- destPoint(ptBottom1,ap1+90,4000)
iRect <- data.frame(rbind(pt1,pt2,pt3,pt4))
#Inner Horizontal Surface
m%>%addCircles(ptBottom1[1],ptBottom1[2],radius = 4000,color = "red",
fillOpacity = 0,weight = 3)%>%
addCircles(ptTop1[1],ptTop1[2],radius = 4000,color = "red",
fillOpacity = 0,weight = 3)%>%
addPolygons(iRect$lon,iRect$lat,color = "blue",
fillOpacity = 0, weight=3)
rgeos
有gUnion()
功能,但我不知道如何已經通過代碼添加上面的圓圈,轉換成SpatialPolygons。
感謝您指出'sf'包。這正是我需要的! – Dhiraj
@Dhiraj - 不客氣。我發現習慣'sf'需要一段時間,但最終這是值得的。 – SymbolixAU
**小冊子**支持所有主要的** sf **類,但是'MULTIPOINT',因此在這裏不需要轉換爲** sp **。 – TimSalabim