I use the sf
R package regularly, but I'm having trouble finding the correct process to use in sf
to get a parallel result to what I would get performing a union in ArcGIS. Given the image below, where I have a set of polygon features in purple, and another polygon feature shown by the heavy black outline, what I want is what I would get from using union in ArcGIS - that is, the purple polygon features sliced on the border of the black polygon, and for the purple features within the black polygon, the attributes would now also contain attributes of my black polygon. For purple features outside the black polygon, they would have the attribute fields of the black polygon but they would have no values populated.
No matter how I parameterize st_union
in sf
, my interior purple polygons are dissolved with the bounding black polygon, and ALL features get all the attritues of the black polygon populated, even those outside the black polygon. What would be the analogous process in sf
to get the result one would have using union in ArcGIS? It's simply a combination of both polygon features I need, where purple polygons are sliced by the black polygon, and features inside get attributes of black polygon feature, while those outside get the attribute fields of the black polygon but un-populated values.
st_intersects
to get the relationship between each set of features and then extracting attributes from the result of that.