momepy icon indicating copy to clipboard operation
momepy copied to clipboard

momepy.Courtyards throws error with multipolygons

Open ale-v opened this issue 2 years ago • 1 comments

Althouhg momepy.Courtyards has a built-in function to avoid errors with multipolygons, it does not seem enough. Here is the traceback of the error:

AttributeError                            Traceback (most recent call last)
<timed exec> in <module>

~\Miniconda3\envs\ox1\lib\site-packages\distributed\client.py in result(self, timeout)
    218         if self.status == "error":
    219             typ, exc, tb = result
--> 220             raise exc.with_traceback(tb)
    221         elif self.status == "cancelled":
    222             raise result

<ipython-input-49-323d2382eac6> in measure()
     36     blg_q1 = libpysal.weights.contiguity.Queen.from_dataframe(cells[cells['buildings'].notna()], geom_col='buildings')
     37 
---> 38     cells['libNCo'] = mm.Courtyards(cells[cells['buildings'].notna()], blg_q1).series
     39     cells['ldbPWL'] = mm.PerimeterWall(cells[cells['buildings'].notna()]).series
     40     cells['mtbSWR'] = mm.SharedWallsRatio(cells[cells['buildings'].notna()]).series

~\Miniconda3\envs\ox1\lib\site-packages\momepy\intensity.py in __init__()
    274                 # buffer to avoid multipolygons where buildings touch by corners only
    275                 dissolved = joined.geometry.buffer(0.01).unary_union
--> 276                 interiors = len(list(dissolved.interiors))
    277                 for b in to_join:
    278                     courtyards[b] = interiors  # fill dict with values

AttributeError: 'MultiPolygon' object has no attribute 'interiors'

ale-v avatar Sep 17 '21 08:09 ale-v

I sense that it is the data issue. Can you share the bit of data causing a trouble? And the rest of your code including affecting this? In theory there shouldn't exist a MultiPolygon at this moment.

martinfleis avatar Sep 17 '21 09:09 martinfleis

Let's close for lack of response? If the OP provides more information we can reopen.

jGaboardi avatar Dec 03 '22 02:12 jGaboardi