Reputation: 1713
I have downloaded two .gdb files from here:
I saved both folders into data folder and unziped them
library(sf)
lots <- st_read("data/Lots_GDB/lots.gdb",layer= "lot")
lots <-st_transform(st_cast(lots , "MULTIPOLYGON"), "+proj=longlat +datum=WGS84")
buildings <- st_read("data/buildings_gdb/buildings.gdb",layer= "buildings")
buildings <-st_transform(st_cast(buildings , "MULTIPOLYGON"), "+proj=longlat +datum=WGS84") %>% select( FACILITYID,FACILITY_TYPE, STATUS)
What I would like to obtain:
I used st_intersection()
to overlap two objects
lots_building<- st_intersection(lots, buildings)
And then plot it on teh map:
ggmap() +
geom_sf(data= lots_building, alpha=0.9, inherit.aes = FALSE)
But somehow lots_building
does not seem to be the right feature to achieve the task.
Upvotes: 0
Views: 1315
Reputation: 1713
I tried many things, but this one is the only thing that worked:
diffPoly <-lots[lengths(st_intersects(lots,buildings))==0,]
Upvotes: 2