I have two objects overlapping each other:
- Multipolygons
- Polylines
Like this:
I need to add a column in the Multipolygons object with the intersected rows from the other object, something like this:
Any ideas how to achieve this using SF library in R?
Given polygons and lines as
sf
class objectspolys
andlins
:This is a list with one element per polygon where the element is a vector of line indexes that intersect the polygon.
You can add this as a "list-column" to the polygons data frame:
Note that list columns break the clean tabular nature of data frames and I'd usually avoid them, it can make further data handling messy...