diff --git a/libpysal/weights/_contW_lists.py b/libpysal/weights/_contW_lists.py index 8fe7cbfe8..ea456b258 100644 --- a/libpysal/weights/_contW_lists.py +++ b/libpysal/weights/_contW_lists.py @@ -17,14 +17,23 @@ def _get_boundary_points(shape): Recursively handle polygons vs. multipolygons to extract the boundary point set from each. """ - if shape.type.lower() == 'polygon': + if shape.type.lower() == "polygon" and \ + isinstance(shape, dict) and \ + 'rings' in shape: + return _get_boundary_points(shape.boundary()) # returns a polyline (path) + elif shape.type.lower() == 'polygon': shape = shape.boundary return _get_boundary_points(shape) + elif shape.type.lower() == 'linestring': return list(map(tuple, list(zip(*shape.coords.xy)))) elif shape.type.lower() == 'multilinestring': return list(it.chain(*(list(zip(*shape.coords.xy)) for shape in shape))) + elif shape.type.lower() == 'polyline': + coords = [] + [coords.extend([tuple(p) for p in path]) for path in shape['paths']] + return coords elif shape.type.lower() == 'multipolygon': return list(it.chain(*(_get_boundary_points(part.boundary) for part in shape)))