From 193d85418e1797168a2d5e221e97ab8602ca3a76 Mon Sep 17 00:00:00 2001 From: Kenn Cartier Date: Wed, 18 Dec 2024 22:20:19 -0800 Subject: [PATCH] partial undo of last PR --- city_metrix/layers/layer.py | 3 ++- city_metrix/layers/nasa_dem.py | 26 ++++++++++---------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/city_metrix/layers/layer.py b/city_metrix/layers/layer.py index 3d2829f..91e6316 100644 --- a/city_metrix/layers/layer.py +++ b/city_metrix/layers/layer.py @@ -2,6 +2,7 @@ from abc import abstractmethod from typing import Union, Tuple from uuid import uuid4 +from osgeo import gdal import ee import boto3 @@ -393,4 +394,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 \ No newline at end of file diff --git a/city_metrix/layers/nasa_dem.py b/city_metrix/layers/nasa_dem.py index d3840d3..d937129 100644 --- a/city_metrix/layers/nasa_dem.py +++ b/city_metrix/layers/nasa_dem.py @@ -1,4 +1,6 @@ import ee +import xee +import xarray as xr from .layer import Layer, get_image_collection @@ -14,20 +16,12 @@ def __init__(self, spatial_resolution=30, **kwargs): self.spatial_resolution = spatial_resolution def get_data(self, bbox): - nasa_dem = ee.Image("NASA/NASADEM_HGT/001") + dataset = ee.Image("NASA/NASADEM_HGT/001") + nasa_dem = ee.ImageCollection(ee.ImageCollection(dataset) + .filterBounds(ee.Geometry.BBox(*bbox)) + .select('elevation') + .mean() + ) + data = get_image_collection(nasa_dem, bbox, self.spatial_resolution, "NASA DEM").elevation - nasa_dem_elev = (ee.ImageCollection(nasa_dem) - .filterBounds(ee.Geometry.BBox(*bbox)) - .select('elevation') - .mean() - ) - - nasa_dem_elev_ic = ee.ImageCollection(nasa_dem_elev) - data = get_image_collection( - nasa_dem_elev_ic, - bbox, - self.spatial_resolution, - "NASA DEM" - ).elevation - - return data + return data \ No newline at end of file