In order to select/identify the border polygons of a shapefile, I would like to use a function able to select/identify polygon that share a line segment with a source polygon.
With figures:
I have this kind of shapefile:

Using gUnionCascaded from rgeos package, I have a second shapefile with the "contour polygon"

Now I am looking for a function that can select/identify border polygons (shaded on the fig) i.e. polygons of the first shapefile that share a line segment with the polygon of the second shapefile . :


