Skip to content

Commit

Permalink
Add max DEM metric
Browse files Browse the repository at this point in the history
  • Loading branch information
chrowe committed Jun 4, 2024
1 parent 8aa2910 commit 99f5655
Show file tree
Hide file tree
Showing 5 changed files with 443 additions and 5 deletions.
3 changes: 3 additions & 0 deletions city_metrix/layers/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def mean(self):

def count(self):
return self._zonal_stats("count")

def max(self):
return self._zonal_stats("max")

def _zonal_stats(self, stats_func):
if box(*self.zones.total_bounds).area <= MAX_TILE_SIZE**2:
Expand Down
3 changes: 2 additions & 1 deletion city_metrix/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
from .built_land_with_high_land_surface_temperature import built_land_with_high_land_surface_temperature
from .mean_tree_cover import mean_tree_cover
from .urban_open_space import urban_open_space
from .natural_areas import natural_areas
from .natural_areas import natural_areas
from .max_dsm import max_dsm
14 changes: 14 additions & 0 deletions city_metrix/metrics/max_dsm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from geopandas import GeoDataFrame, GeoSeries

from city_metrix.layers import AlosDSM
from exactextract import exact_extract

def max_dsm(zones: GeoDataFrame) -> GeoSeries:
"""
Get max AlosDSM.
:param zones: GeoDataFrame with geometries to collect zonal stats on
:return: Pandas Series of hights
"""
max_height = exact_extract(AlosDSM(), zones, ["max"])

return max_height
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ dependencies:
- pip=23.3.1
- pip:
- cartoframes==1.2.5
- git+https://github.com/isciences/exactextract
Loading

0 comments on commit 99f5655

Please sign in to comment.