Skip to content

Commit

Permalink
ENH: adapt code for ET (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfleis authored Dec 9, 2020
1 parent f99c692 commit 18eb023
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions momepy/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
-----
Expand Down Expand Up @@ -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
)

Expand Down
6 changes: 4 additions & 2 deletions momepy/intensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 18eb023

Please sign in to comment.