Skip to content

Commit

Permalink
Enhance DEM processing when AOI defined by GeoSeries
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyPechnikov committed Jan 22, 2024
1 parent 12719ac commit 66d2a6e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pygmtsar/pygmtsar/Stack_dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def download_dem(self, geometry='auto', product='1s'):
This method uses the GMT servers to download SRTM 1 or 3 arc-second DEM data. The downloaded data is then
preprocessed by removing the EGM96 geoid to make the heights relative to the WGS84 ellipsoid.
"""
import pandas as pd
import geopandas as gpd
import xarray as xr
import numpy as np
import pygmt
Expand Down Expand Up @@ -232,8 +232,10 @@ def download_dem(self, geometry='auto', product='1s'):
if type(geometry) == str and geometry == 'auto':
# apply scenes geometry
geometry = self.get_extent().buffer(self.buffer_degrees)
elif isinstance(geometry, pd.DataFrame):
elif isinstance(geometry, gpd.GeoDataFrame):
geometry = geometry.dissolve().envelope.item()
elif isinstance(geometry, gpd.GeoSeries):
geometry = geometry.unary_union.envelope
minx, miny, maxx, maxy = np.round(geometry.bounds, 5)
#print ('minx, miny, maxx, maxy', minx, miny, maxx, maxy)

Expand Down Expand Up @@ -279,7 +281,7 @@ def load_dem(self, filename, geometry='auto'):
import xarray as xr
import numpy as np
import rioxarray as rio
import pandas as pd
import geopandas as gpd
import os

dem_filename = os.path.join(self.basedir, 'DEM_WGS84.nc')
Expand All @@ -305,7 +307,7 @@ def load_dem(self, filename, geometry='auto'):
if type(geometry) == str and geometry == 'auto':
# apply scenes geometry
extent = self.get_extent().buffer(self.buffer_degrees)
elif isinstance(geometry, pd.DataFrame):
elif isinstance(geometry, gpd.GeoDataFrame):
extent = geometry.dissolve().envelope.item()
#minx, miny, maxx, maxy = np.round(geometry.bounds, 5)
#print ('minx, miny, maxx, maxy', minx, miny, maxx, maxy)
Expand Down

0 comments on commit 66d2a6e

Please sign in to comment.