Построение внутренней горизонтальной поверхности взлетно-посадочной полосы

Ранее я опубликовал проблему объединения кругов здесь. С помощью сообщества это было решено. Однако теперь, когда я пытаюсь объединить полигон с существующей геометрией, я не вижу желаемого результата. Это то, что я пробовал:

library(leaflet)
library(sf)
library(rgeos)
library(geosphere)

#Dimensions of runway1
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 #Approach

#########################################
#Inner Horizontal Surface

#Convert into a dataframe
df1 <- data.frame(lon=c(ptTop1[1],ptBottom1[1]),
                  lat=c(ptTop1[2],ptBottom1[2]))

#Convert into a simple features data.frmae
sf_df1 <- st_as_sf(df1, coords = c("lon","lat"))

#Convert into circles
sf_circles1 <- st_buffer(sf_df1,dist=0.04)

#Coordinates of the rectangle
pt1 <- destPoint(ptTop1,ap1+90,4000)
pt2 <- destPoint(ptTop1,ap1-90,4000)
pt3 <- destPoint(ptBottom1,ap1-90,4000)
pt4 <- destPoint(ptBottom1,ap1+90,4000)

#Convert into a dataframe
iRect1 <- data.frame(lon=c(pt1[1],pt2[1],pt3[1],pt4[1]),
                     lat=c(pt1[2],pt2[2],pt3[2],pt4[2]))
#Convert into a simple features df
sf_iRect1 <- st_as_sf(iRect1,coords = c("lon","lat"))
rect1 <- st_sfc(st_polygon(list(cbind(lon=c(pt1[1],pt2[1],pt3[1],pt4[1],pt1[1]),
                               lat=c(pt1[2],pt2[2],pt3[2],pt4[2],pt1[2])))))

#Combine the 3 shapes
sf_combined1 <- st_union(sf_circles1)
sf_combined2 <- st_union(sf_combined1,rect1,by_feature = F)
#Plot in leaflet
sp <- as(sf_combined2,'Spatial')#as(st_sfc(sf_combined1), "Spatial")
sp%>%leaflet()%>%addTiles()%>%
  addProviderTiles(providers$Esri.WorldImagery, group ="ESRI")%>%
  addPolygons()

Может кто-нибудь, пожалуйста, скажите мне, что я делаю неправильно?


person Dhiraj    schedule 13.08.2017    source источник
comment
Если вы хотите, чтобы взлетно-посадочная полоса была исключена из круга(ов), то st_sym_difference(sf_combined1, rect1) должен дать вам то, что вы хотите.   -  person TimSalabim    schedule 13.08.2017
comment
@TimSalabim спасибо. Но боюсь, это не то, чего я хочу. Я хочу объединить прямоугольник, нарисованный вокруг взлетно-посадочной полосы (rect1), с двумя кругами, нарисованными ранее.   -  person Dhiraj    schedule 13.08.2017
comment
Я только что понял, что границы моего прямоугольника находятся внутри кругов, и поэтому я не мог видеть их перекрывающимися! Виноват.   -  person Dhiraj    schedule 13.08.2017