Skip to content

Commit

Permalink
correct pop-weighted indicator calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
tedw0ng committed Jan 13, 2025
1 parent 58a64c8 commit ffc15ed
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions city_metrix/metrics/count_accessible_amenities.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ def _count_accessible_amenities(zones: GeoDataFrame, cityname, amenityname, trav
if weighting == 'area':
result = population_layer.mask(count_layers[1]).groupby(zones).count()
for count in range(2, max_count+1):
result += population_layer.mask(count_layers[count]).groupby(zones).count() * count
result += population_layer.mask(count_layers[count]).groupby(zones).count()
result = result / population_layer.groupby(zones).count()
else: # weighting == 'population'
result = population_layer.mask(count_layers[1]).groupby(zones).sum()
for count in range(2, max_count+1):
result += population_layer.mask(count_layers[count]).groupby(zones).sum()
result = result / population_layer.groupby(zones).count()
result = result / population_layer.groupby(zones).sum()
result_gdf = GeoDataFrame({'count_accessible_amenities': result, 'geometry': zones['geometry']}).set_crs('EPSG:4326')
return result_gdf.count_accessible_amenities

Expand Down

0 comments on commit ffc15ed

Please sign in to comment.