Skip to content

Commit

Permalink
Merge pull request #66 from wri/add_impervious_surface_layer
Browse files Browse the repository at this point in the history
Create impervious_surface.py
  • Loading branch information
chrowe authored Sep 6, 2024
2 parents a74f98c + 4a169d9 commit 5157ebc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions city_metrix/layers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
from .alos_dsm import AlosDSM
from .overture_buildings import OvertureBuildings
from .nasa_dem import NasaDEM
from .impervious_surface import ImperviousSurface
23 changes: 23 additions & 0 deletions city_metrix/layers/impervious_surface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from dask.diagnostics import ProgressBar
import xarray as xr
import xee
import ee

from .layer import Layer, get_utm_zone_epsg, get_image_collection


class ImperviousSurface(Layer):
def __init__(self, **kwargs):
super().__init__(**kwargs)

def get_data(self, bbox):
# load impervious_surface
dataset = ee.ImageCollection(ee.Image("Tsinghua/FROM-GLC/GAIA/v10").gt(0)) # change_year_index is zero if permeable as of 2018
imperv_surf = ee.ImageCollection(dataset
.filterBounds(ee.Geometry.BBox(*bbox))
.select('change_year_index')
.sum()
)

data = get_image_collection(imperv_surf, bbox, 100, "imperv surf")
return data.change_year_index
6 changes: 6 additions & 0 deletions tests/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
EsaWorldCover,
EsaWorldCoverClass,
HighLandSurfaceTemperature,
ImperviousSurface,
LandsatCollection2,
LandSurfaceTemperature,
NasaDEM,
Expand Down Expand Up @@ -82,6 +83,11 @@ def test_high_land_surface_temperature():
assert data.any()


def test_impervious_surface():
data = ImperviousSurface().get_data(BBOX)
assert data.any()


def test_land_surface_temperature():
mean_lst = LandSurfaceTemperature().get_data(BBOX).mean()
assert mean_lst
Expand Down

0 comments on commit 5157ebc

Please sign in to comment.