Skip to content

Commit

Permalink
Merge pull request #100 from wri/CIF-315-Improve-consistency-and-stan…
Browse files Browse the repository at this point in the history
…dardization-of-CIF-code-for-Layers

Cif 315 improve consistency and standardization of cif code for layers
  • Loading branch information
kcartier-wri authored Dec 19, 2024
2 parents fbc5a58 + eabbbe7 commit feed9b6
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ To run the module,

1. You need access to Google Earth Engine
2. Install <https://cloud.google.com/sdk/docs/install>
3. If you want to use the ERA5 layer, you need to install the [Climate Data Store (CDS) Application Program Interface (API)](https://cds.climate.copernicus.eu/api-how-to)
3. If you want to use the ERA5 layer, you need to install the [Climate Data Store (CDS) Application Program Interface (API)](https://cds.climate.copernicus.eu/how-to-api)

### Interactive development

Expand Down
5 changes: 4 additions & 1 deletion city_metrix/layers/albedo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import ee
import xarray
from dask.diagnostics import ProgressBar

from .layer import Layer, get_utm_zone_epsg, get_image_collection

from .layer import Layer, get_image_collection

class Albedo(Layer):
"""
Expand Down
3 changes: 3 additions & 0 deletions city_metrix/layers/alos_dsm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import ee
import xee
import xarray as xr


from .layer import Layer, get_image_collection

Expand Down
5 changes: 4 additions & 1 deletion city_metrix/layers/average_net_building_height.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from dask.diagnostics import ProgressBar
import xarray as xr
import xee
import ee

from .layer import Layer, get_image_collection
from .layer import Layer, get_utm_zone_epsg, get_image_collection


class AverageNetBuildingHeight(Layer):
Expand Down
5 changes: 4 additions & 1 deletion city_metrix/layers/built_up_height.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from dask.diagnostics import ProgressBar
import xarray as xr
import xee
import ee

from .layer import Layer, get_image_collection
from .layer import Layer, get_utm_zone_epsg, get_image_collection


class BuiltUpHeight(Layer):
Expand Down
6 changes: 4 additions & 2 deletions city_metrix/layers/esa_world_cover.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from dask.diagnostics import ProgressBar
from enum import Enum
import xarray as xr
import ee

from enum import Enum
from .layer import Layer, get_image_collection
from .layer import Layer, get_utm_zone_epsg, get_image_collection


class EsaWorldCoverClass(Enum):
Expand Down
2 changes: 1 addition & 1 deletion city_metrix/layers/glad_lulc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import xarray as xr
import ee

from .layer import Layer, get_image_collection
from .layer import Layer, get_utm_zone_epsg, get_image_collection


class LandCoverGlad(Layer):
Expand Down
8 changes: 4 additions & 4 deletions city_metrix/layers/high_land_surface_temperature.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import datetime
import ee

from shapely.geometry import box
from .landsat_collection_2 import LandsatCollection2
from .land_surface_temperature import LandSurfaceTemperature
from .layer import Layer
from shapely.geometry import box
import datetime
import ee

class HighLandSurfaceTemperature(Layer):
"""
Expand Down
5 changes: 4 additions & 1 deletion city_metrix/layers/impervious_surface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from dask.diagnostics import ProgressBar
import xarray as xr
import xee
import ee

from .layer import Layer, get_image_collection
from .layer import Layer, get_utm_zone_epsg, get_image_collection


class ImperviousSurface(Layer):
Expand Down
6 changes: 4 additions & 2 deletions city_metrix/layers/land_surface_temperature.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from .landsat_collection_2 import LandsatCollection2
from .layer import Layer, get_utm_zone_epsg, get_image_collection
from dask.diagnostics import ProgressBar
import ee

from .layer import Layer, get_image_collection
import xarray

class LandSurfaceTemperature(Layer):
"""
Expand Down
4 changes: 3 additions & 1 deletion city_metrix/layers/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from abc import abstractmethod
from typing import Union, Tuple
from uuid import uuid4
# This osgeo import is essential for proper functioning. Do not remove.
from osgeo import gdal

import ee
import boto3
Expand Down Expand Up @@ -393,4 +395,4 @@ def offset_meters_to_geographic_degrees(decimal_latitude, length_m):
lon_degree_offset = abs((length_m / (earth_radius_m * math.cos(math.pi*decimal_latitude/180))) * rad)
lat_degree_offset = abs((length_m / earth_radius_m) * rad)

return lon_degree_offset, lat_degree_offset
return lon_degree_offset, lat_degree_offset
4 changes: 3 additions & 1 deletion city_metrix/layers/nasa_dem.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import ee
import xee
import xarray as xr

from .layer import Layer, get_image_collection

Expand Down Expand Up @@ -29,5 +31,5 @@ def get_data(self, bbox):
self.spatial_resolution,
"NASA DEM"
).elevation

return data
1 change: 1 addition & 0 deletions city_metrix/layers/natural_areas.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import xarray as xr
from xrspatial.classify import reclassify

from .layer import Layer
Expand Down
2 changes: 2 additions & 0 deletions city_metrix/layers/smart_surface_lulc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import xarray as xr
import numpy as np
import pandas as pd
import geopandas as gpd
from shapely.geometry import CAP_STYLE, JOIN_STYLE
from shapely.geometry import box
from exactextract import exact_extract
from geocube.api.core import make_geocube
import warnings
Expand Down
7 changes: 5 additions & 2 deletions city_metrix/layers/tree_canopy_height.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import ee
from .layer import Layer, get_utm_zone_epsg, get_image_collection

from .layer import Layer, get_image_collection
from dask.diagnostics import ProgressBar
import xarray as xr
import xee
import ee

class TreeCanopyHeight(Layer):
"""
Expand Down
6 changes: 5 additions & 1 deletion city_metrix/layers/tree_cover.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from .layer import Layer, get_utm_zone_epsg, get_image_collection

from dask.diagnostics import ProgressBar
import xarray as xr
import xee
import ee

from .layer import Layer, get_image_collection

class TreeCover(Layer):
"""
Expand Down
5 changes: 4 additions & 1 deletion city_metrix/layers/urban_land_use.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from dask.diagnostics import ProgressBar
import xarray as xr
import xee
import ee

from .layer import Layer, get_image_collection
from .layer import Layer, get_utm_zone_epsg, get_image_collection


class UrbanLandUse(Layer):
Expand Down
5 changes: 4 additions & 1 deletion city_metrix/layers/world_pop.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from dask.diagnostics import ProgressBar
import xarray as xr
import xee
import ee

from .layer import Layer, get_image_collection
from .layer import Layer, get_utm_zone_epsg, get_image_collection


class WorldPop(Layer):
Expand Down

0 comments on commit feed9b6

Please sign in to comment.