I have two polygon vector layers one of which has more than 100,000 polygons. There are areas of overlap in the two vector layers however they have different attributes. In the final layer I want the attributes to come across from both the polygon layers especially where the polygons in the two layers overlap. I have to do further processing on this attribute intersect information hence it is critical.
I already know how to do this in R (using the
union function as part of the
raster package) because that's where I'm carrying out most of the post-processing of this data however it is extremely slow. Slow to the point that it continues to do the
union even after 2 hours and which it crashes. In QGIS, it takes less than a couple of minutes but I want to run it as a routine process so want to avoid using QGIS.
I have since then tried to do this using ogr2ogr and I am not getting the desired result. For example, I have followed this particular thread and the result is not what I am after. What I am getting at the end is a massive shapefile with the attributes of the two layers combined into 1 but no mapping of the attributes where the intersection has occurred as such. It almost looks like the two shapefiles have been merged without any intersection occurring between them which is what I am after.
Isn't there a union function in ogr2ogr similar to the one in QGIS? Or can anyone suggest how I can expedite this union process in R?