Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Julien Michel
sensorsio
Commits
78e1588d
Commit
78e1588d
authored
Dec 24, 2021
by
Jordi Inglada
Browse files
DOC: some docstrings for SRTM
parent
5d28e331
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sensorsio/srtm.py
View file @
78e1588d
...
...
@@ -71,22 +71,40 @@ class SRTM:
base_dir
:
str
=
"/datalake/static_aux/MNT/SRTM_30_hgt"
def
get_dem_from_tiles
(
self
,
tiles
:
List
[
SRTMTileId
])
->
DEM
:
elevation
,
transform
=
self
.
build_hgt
(
tiles
)
"""Build a DEM (elevation, slope and aspect) for a list of (supposedly
adjacent) SRTM tiles. It keeps CRS and extent of the SRTM tiles.
"""
elevation
,
transform
=
self
.
__build_hgt
(
tiles
)
elevation
=
elevation
[
0
,
:,
:]
x
,
y
=
np
.
gradient
(
elevation
.
astype
(
np
.
float16
))
slope
=
np
.
degrees
(
np
.
pi
/
2.
-
np
.
arctan
(
np
.
sqrt
(
x
*
x
+
y
*
y
)))
aspect
=
np
.
degrees
(
np
.
arctan2
(
-
x
,
y
))
return
DEM
(
elevation
,
slope
,
aspect
,
transform
)
return
DEM
(
elevation
.
astype
(
np
.
int16
),
slope
.
astype
(
np
.
int16
),
aspect
.
astype
(
np
.
int16
),
crs
=
'+proj=latlong'
,
transform
=
transform
)
def
get_dem_for_mgrs_tile
(
self
,
tile
:
str
)
->
DEM
:
"""Build a DEM (elevation, slope and aspect) for an MGRS tile with the
union of the intersecting SRTM tiles. It keeps CRS and extent of the
SRTM tiles.
"""
srtm_tiles
=
srtm_tiles_from_mgrs_tile
(
tile
)
return
self
.
get_dem_from_tiles
(
srtm_tiles
)
def
get_dem_for_bbox
(
self
,
bbox
:
BoundingBox
)
->
DEM
:
"""Build a DEM (elevation, slope and aspect) for a bounding box with the
union of the intersecting SRTM tiles. It keeps CRS and extent of the
SRTM tiles.
"""
srtm_tiles
=
srtm_tiles_from_bbox
(
bbox
)
return
self
.
get_dem_from_tiles
(
srtm_tiles
)
def
build_hgt
(
def
__
build_hgt
(
self
,
tiles
:
List
[
SRTMTileId
]
)
->
Tuple
[
np
.
ndarray
,
rio
.
transform
.
Affine
]:
file_names
=
[
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment