Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion libpysal/weights/_contW_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down