Skip to content

Commit

Permalink
partial undo of last PR
Browse files Browse the repository at this point in the history
  • Loading branch information
kcartier-wri committed Dec 19, 2024
1 parent 0c8b93e commit 193d854
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
3 changes: 2 additions & 1 deletion city_metrix/layers/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
26 changes: 10 additions & 16 deletions 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 All @@ -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

0 comments on commit 193d854

Please sign in to comment.