-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from wri/CIF-221-METRIC-Recreational-space-per…
…-capita CIF-221 add recreational space per capita indicator
- Loading branch information
Showing
7 changed files
with
48 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from geopandas import GeoDataFrame, GeoSeries | ||
|
||
from city_metrix.layers import WorldPop, OpenStreetMap, OpenStreetMapClass | ||
|
||
|
||
def recreational_space_per_capita(zones: GeoDataFrame, spatial_resolution=100) -> GeoSeries: | ||
world_pop = WorldPop(spatial_resolution=spatial_resolution) | ||
open_space = OpenStreetMap(osm_class=OpenStreetMapClass.OPEN_SPACE) | ||
|
||
# per 1000 people | ||
world_pop_sum = world_pop.groupby(zones).sum() / 1000 | ||
# convert square meter to hectare | ||
open_space_counts = open_space.mask(world_pop).groupby(zones).count() | ||
open_space_area = open_space_counts.fillna(0) * spatial_resolution ** 2 / 10000 | ||
|
||
return open_space_area / world_pop_sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters