I'm quite new to GIS so sorry if this is a daft question - is it possible to filter out non-overlapping parts of a shapefile? I have a boundary shapefile which I would like to cover with small areas from another shapefile. The small areas don't neatly fit inside the boundary, so filtering gives the wrong final shape.
In the picture, I'm trying to just get the areas which are entirely inside the red boundary, plus the parts of the 'overlapping' areas which are inside the red boundary. I'm using R and
sf, but I'm happy to switch to QGIS if it's easier to do this sort of operation there. The code below makes a simpler version what I'm tring for - ideally I'd like to make a third shapefile which is the square & the part of the triangle contained inside the larger shape
p1 = st_polygon(list(rbind(c(1, 5), c(2, 2), c(4, 1), c(4, 4), c(1, 5)))) p2 = st_polygon(list(rbind(c(2, 3), c(2, 4), c(3, 4), c(3, 3), c(2, 3)))) p3 = st_polygon(list(rbind(c(2, 1.5), c(2.5, 2.5), c(2.5, 1), c(2, 1.5)))) big = st_as_sf(st_as_sfc(st_as_text(p1))) small1 = st_as_sf(st_as_sfc(st_as_text(p2))) small2 = st_as_sf(st_as_sfc(st_as_text(p3))) small = bind_rows(small1, small2) %>% mutate(shape = c('square', 'triangle')) ggplot() + geom_sf(data = big) + geom_sf(data = small)
Ideally I'd like to get just the highlighted shapes