I have a SpatialPolygonsDataFrame and I would like to create an adjacency matrix. However, I would like to only count two polygons as adjacent if they share more than just vertices (i.e. they share an edge, not just a point). gTouches says polygons are adjacent if they share at least one point (e.g. just one vertex).
My thought was to run:
AdjMat <- gTouches(map, byid=TRUE)
then go look at the intersections for the adjacent polygons that identifies to see if the intersection is a line or a point.
test <- gIntersection(map[x,],map[y,]) exists("test@lines")
Playing around I find "test" is "Formal class SpatialLines" if x and y share an edge, and "Formal class SpatialPoints" if they just share a vertex (and "NULL (empty)" if they aren't adjacent at all. The problem I'm having is that even when it is "Formal class SpatialLines" and "test@lines" is actually in my environment, exists("test@lines") returns FALSE. (When it is "Formal class SpatialPoints, "test@lines" is not available, but "test@coords" is, but exists("test@coords") also returns FALSE.)
How do I get an adjacency matrix that doesn't count polygons as adjacent if their shared boundary/intersection is only one-dimensional?