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
5401edff
Commit
5401edff
authored
Jan 18, 2022
by
Jordi Inglada
Browse files
REFAC: use rasterio's BoundingBox
parent
0bd605b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sensorsio/srtm.py
View file @
5401edff
...
...
@@ -10,23 +10,12 @@ import geopandas as gpd
import
numpy
as
np
import
rasterio
as
rio
from
pyproj
import
CRS
,
Transformer
from
rasterio.coords
import
BoundingBox
from
rasterio.merge
import
merge
from
rasterio.warp
import
Resampling
,
reproject
from
shapely.geometry
import
Polygon
class
BoundingBox
:
"""
Class modeling a lat, long bounding box
"""
def
__init__
(
self
,
lonmin
:
float
,
latmin
:
float
,
lonmax
:
float
,
latmax
:
float
):
self
.
lonmin
=
min
(
lonmax
,
lonmin
)
self
.
latmin
=
min
(
latmax
,
latmin
)
self
.
lonmax
=
max
(
lonmax
,
lonmin
)
self
.
latmax
=
max
(
latmax
,
latmin
)
@
dataclass
(
frozen
=
True
)
class
SRTMTileId
:
""" Class modeling a SRTM tile """
...
...
@@ -44,13 +33,13 @@ class SRTMTileId:
def
srtm_tiles_from_bbox
(
bbox
:
BoundingBox
)
->
List
[
SRTMTileId
]:
""" Return a list of SRTMTileId intersecting a bounding box"""
latmin
=
int
(
np
.
floor
(
bbox
.
latmin
))
latmax
=
int
(
np
.
floor
(
bbox
.
latmax
))
l
onmin
=
int
(
np
.
floor
(
bbox
.
l
onmin
))
lonmax
=
int
(
np
.
floor
(
bbox
.
lonmax
))
bottom
=
int
(
np
.
floor
(
bbox
.
bottom
))
top
=
int
(
np
.
floor
(
bbox
.
top
))
l
eft
=
int
(
np
.
floor
(
bbox
.
l
eft
))
right
=
int
(
np
.
floor
(
bbox
.
right
))
return
[
SRTMTileId
(
lon
,
lat
)
for
lat
in
range
(
latmin
,
latmax
+
1
)
for
lon
in
range
(
l
onmin
,
lonmax
+
1
)
SRTMTileId
(
lon
,
lat
)
for
lat
in
range
(
bottom
,
top
+
1
)
for
lon
in
range
(
l
eft
,
right
+
1
)
]
...
...
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