Commit 17e975ad authored by Kris Vanneste's avatar Kris Vanneste
Browse files

Simplified extract_elevation_from_dem function based on functionality in grid.py.

git-svn-id: https://svn.seismo.oma.be/svn/seismo/mapping/layeredbasemap/trunk@7548 40b490c5-b4d9-47cb-8714-9bef99b524d5
parent 10dff3f9
......@@ -10,9 +10,11 @@ import numpy as np
from secrets.geoserver import host
URL = 'http://%s/geoserver' % host
WCS_URL = "%s/wcs" % URL
__all__ = ['extract_elevation_from_dem']
__all__ = [URL, WCS_URL, 'extract_elevation_from_dem']
def extract_elevation_from_dem(xdata, ydata, dem_name, resolution=0, order=1):
......@@ -27,7 +29,7 @@ def extract_elevation_from_dem(xdata, ydata, dem_name, resolution=0, order=1):
:param dem_name:
str, layer name of DEM on Geoserver
Known layer names are: 'ngi:DTM10k', 'agiv:DTM5m', 'agiv:DTM1m',
'ahn2:AHN2_5m' and "wallonie:MNT_1m_2013-2014"
'ahn:AHN2_5m', 'ahn:AHN3_05m', 'nrw:DGM1' and "wallonie:MNT_1m_2013-2014"
:param resolution:
float, resolution of DEM in native units
(default: 0, will use best resolution available)
......@@ -39,28 +41,9 @@ def extract_elevation_from_dem(xdata, ydata, dem_name, resolution=0, order=1):
:return:
numpy float array, elevations in m
"""
from ..data_types import WCSData
url = "%s/wcs" % URL
from .grid import extract_grid_data
if not resolution:
if dem_name == 'agiv:DTM5m':
resolution = 5
elif dem_name == 'agiv:DTM1m':
resolution = 1
elif dem_name == 'ngi:DTM10k':
resolution = 20
elif dem_name == 'ahn2:AHN2_5m':
resolution = 5
elevs = extract_grid_data(dem_name, xdata, ydata, resolution=resolution,
order=order)
xdata = np.asarray(xdata)
ydata = np.asarray(ydata)
xmin = np.floor(xdata.min() / resolution) * resolution
xmax = np.ceil(xdata.max() / resolution) * resolution
ymin = np.floor(ydata.min() / resolution) * resolution
ymax = np.ceil(ydata.max() / resolution) * resolution
bbox = (xmin, ymin, xmax, ymax)
print(bbox)
wcs_data = WCSData(url, dem_name, resolution=resolution, bbox=bbox)
elevs = wcs_data.interpolate(xdata, ydata, order=order)
return elevs
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment