diff --git a/momepy/distribution.py b/momepy/distribution.py index 76a48ce5..31fbecdc 100644 --- a/momepy/distribution.py +++ b/momepy/distribution.py @@ -492,7 +492,7 @@ def __init__(self, gdf, spatial_weights, unique_id, verbose=True): for index, geom in tqdm( data.iteritems(), total=data.shape[0], disable=not verbose ): - if index in spatial_weights.neighbors.keys(): + if geom is not None and index in spatial_weights.neighbors.keys(): neighbours = spatial_weights.neighbors[index] building_neighbours = data.loc[neighbours] if len(building_neighbours) > 0: @@ -543,7 +543,7 @@ class MeanInterbuildingDistance: sw_higher : libpysal.weights Spatial weights matrix of higher order order : int - Order of contiguity. + Order of contiguity. Notes ----- @@ -580,8 +580,8 @@ def __init__( adj_list = spatial_weights.to_adjlist() adj_list["weight"] = ( data.loc[adj_list.focal] - .reset_index() - .distance(data.loc[adj_list.neighbor].reset_index()) + .reset_index(drop=True) + .distance(data.loc[adj_list.neighbor].reset_index(drop=True)) .values ) diff --git a/momepy/intensity.py b/momepy/intensity.py index 5ea33614..3cf79c92 100644 --- a/momepy/intensity.py +++ b/momepy/intensity.py @@ -249,12 +249,14 @@ def __init__(self, gdf, block_id=None, spatial_weights=None, verbose=True): # dict to store nr of courtyards for each uID courtyards = {} components = pd.Series(spatial_weights.component_labels, index=gdf.index) - for index in tqdm(gdf.index, total=gdf.shape[0], disable=not verbose): + for i, index in tqdm( + enumerate(gdf.index), total=gdf.shape[0], disable=not verbose + ): # if the id is already present in courtyards, continue (avoid repetition) if index in courtyards: continue else: - comp = spatial_weights.component_labels[index] + comp = spatial_weights.component_labels[i] to_join = components[components == comp].index joined = gdf.loc[to_join] dissolved = joined.geometry.buffer(