Skip to content

Commit

Permalink
get DEM basic wms support
Browse files Browse the repository at this point in the history
  • Loading branch information
domlysz committed May 17, 2024
1 parent 57fd198 commit b3e6a6a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
20 changes: 14 additions & 6 deletions operators/io_get_dem.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ def execute(self, context):
self.report({'ERROR'}, "Too large extent")
return {'CANCELLED'}

bbox = reprojBbox(geoscn.crs, 4326, bbox)
bboxLatLon = reprojBbox(geoscn.crs, 4326, bbox)

if 'SRTM' in prefs.demServer:
if bbox.ymin > 60:
if bboxLatLon.ymin > 60:
self.report({'ERROR'}, "SRTM is not available beyond 60 degrees north")
return {'CANCELLED'}
if bbox.ymax < -56:
if bboxLatLon.ymax < -56:
self.report({'ERROR'}, "SRTM is not available below 56 degrees south")
return {'CANCELLED'}

Expand All @@ -104,10 +104,18 @@ def execute(self, context):
#url template
#http://opentopo.sdsc.edu/otr/getdem?demtype=SRTMGL3&west=-120.168457&south=36.738884&east=-118.465576&north=38.091337&outputFormat=GTiff
e = 0.002 #opentopo service does not always respect the entire bbox, so request for a little more
xmin, xmax = bbox.xmin - e, bbox.xmax + e
ymin, ymax = bbox.ymin - e, bbox.ymax + e
xmin, xmax = bboxLatLon.xmin - e, bboxLatLon.xmax + e
ymin, ymax = bboxLatLon.ymin - e, bboxLatLon.ymax + e

url = prefs.demServer
if "{WIDTH}" in url and "{HEIGHT}" in url:
targetRes = 5
w = bbox.dimensions.x / targetRes
h = bbox.dimensions.y / targetRes
url = url.format(W=xmin, E=xmax, S=ymin, N=ymax, WIDTH=w, HEIGHT=h)
else:
url = url.format(W=xmin, E=xmax, S=ymin, N=ymax, API_KEY=prefs.opentopography_api_key)

url = prefs.demServer.format(W=xmin, E=xmax, S=ymin, N=ymax, API_KEY=prefs.opentopography_api_key)
log.debug(url)

# Download the file from url and save it locally
Expand Down
3 changes: 2 additions & 1 deletion prefs.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def getAppData():
DEFAULT_DEM_SERVER = [
("https://portal.opentopography.org/API/globaldem?demtype=SRTMGL1&west={W}&east={E}&south={S}&north={N}&outputFormat=GTiff&API_Key={API_KEY}", 'OpenTopography SRTM 30m', 'OpenTopography.org web service for SRTM 30m global DEM'),
("https://portal.opentopography.org/API/globaldem?demtype=SRTMGL3&west={W}&east={E}&south={S}&north={N}&outputFormat=GTiff&API_Key={API_KEY}", 'OpenTopography SRTM 90m', 'OpenTopography.org web service for SRTM 90m global DEM'),
("http://www.gmrt.org/services/GridServer?west={W}&east={E}&south={S}&north={N}&layer=topo&format=geotiff&resolution=high", 'Marine-geo.org GMRT', 'Marine-geo.org web service for GMRT global DEM (terrestrial (ASTER) and bathymetry)')
("http://www.gmrt.org/services/GridServer?west={W}&east={E}&south={S}&north={N}&layer=topo&format=geotiff&resolution=high", 'Marine-geo.org GMRT', 'Marine-geo.org web service for GMRT global DEM (terrestrial (ASTER) and bathymetry)'),
("https://data.geopf.fr/wms-r/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&STYLES=normal&FORMAT=image/geotiff&LAYERS=ELEVATION.ELEVATIONGRIDCOVERAGE.HIGHRES&WIDTH={WIDTH}&HEIGHT={HEIGHT}&CRS=EPSG:4326&BBOX={S},{W},{N},{E}", 'Geoplateforme', 'Elevation data from IGN')
]

DEFAULT_OVERPASS_SERVER = [
Expand Down

0 comments on commit b3e6a6a

Please sign in to comment.