-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvegetation_water_change.py
26 lines (16 loc) · 1.13 KB
/
vegetation_water_change.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from geopandas import GeoDataFrame, GeoSeries
from city_metrix.layers import VegetationWaterMap
# TODO: layer generation and zonal stats use different spatial resolutions
def vegetation_water_change_gain_area(zones: GeoDataFrame, spatial_resolution=10) -> GeoSeries:
gain_counts = VegetationWaterMap(greenwater_layer='gaingreenwaterSlope').groupby(zones).count()
gain_area = gain_counts * spatial_resolution ** 2
return gain_area
def vegetation_water_change_loss_area(zones: GeoDataFrame, spatial_resolution=10) -> GeoSeries:
loss_counts = VegetationWaterMap(greenwater_layer='lossgreenwaterSlope').groupby(zones).count()
loss_area = loss_counts * spatial_resolution ** 2
return loss_area
def vegetation_water_change_gain_loss_ratio(zones: GeoDataFrame) -> GeoSeries:
start_counts = VegetationWaterMap(greenwater_layer='startgreenwaterIndex').groupby(zones).count()
loss_counts = VegetationWaterMap(greenwater_layer='lossgreenwaterSlope').groupby(zones).count()
gain_counts = VegetationWaterMap(greenwater_layer='gaingreenwaterSlope').groupby(zones).count()
return (gain_counts - loss_counts) / start_counts