Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add max DSM metric #45

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading