I have a collection of geographies in a GeoPandas GeoDataFrame. I want to construct LineStrings comprising only the boundaries between those geographies, and none of the boundaries in the overall outer boundary of the collection.
By way of visual explanation, I have this:
I want this:
One obvious way to generate this is by dissolving the collection and taking the set difference between the two, like this:
df.boundary.unary_union - df.dissolve().boundary[0]
This does construct the desired geometry, but it's not very performant, and frequently crashes the runtime on my commodity hardware.
Is there a more efficient way of accomplishing this?