Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jonathan Lambrechts
seamsh
Commits
1d7c5d06
Commit
1d7c5d06
authored
Sep 18, 2020
by
Jonathan Lambrechts
Browse files
fix raster projection (rotation + axis order gdal 2 and 3)
parent
75236dc0
Pipeline
#8293
passed with stages
in 2 minutes and 46 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
seamsh/field.py
View file @
1d7c5d06
...
...
@@ -89,10 +89,10 @@ class Raster:
src_ds
=
gdal
.
Open
(
filename
)
self
.
_geo_matrix
=
src_ds
.
GetGeoTransform
()
self
.
_data
=
src_ds
.
GetRasterBand
(
1
).
ReadAsArray
()
assert
(
self
.
_geo_matrix
[
2
]
==
0.
)
assert
(
self
.
_geo_matrix
[
4
]
==
0.
)
self
.
_projection
=
osr
.
SpatialReference
()
self
.
_projection
.
ImportFromWkt
(
src_ds
.
GetProjection
())
if
int
(
gdal
.
__version__
.
split
(
"."
)[
0
])
>=
3
:
self
.
_projection
.
SetAxisMappingStrategy
(
osr
.
OAMS_TRADITIONAL_GIS_ORDER
)
def
__call__
(
self
,
x
:
np
.
ndarray
,
projection
:
osr
.
SpatialReference
)
->
np
.
ndarray
:
...
...
@@ -106,6 +106,8 @@ class Raster:
"""
x
=
_ensure_valid_points
(
x
,
projection
,
self
.
_projection
)
gm
=
self
.
_geo_matrix
xi
=
(
x
[:,
0
]
-
gm
[
3
])
/
gm
[
5
]
eta
=
(
x
[:,
1
]
-
gm
[
0
])
/
gm
[
1
]
return
self
.
_data
[
xi
.
astype
(
int
),
eta
.
astype
(
int
)]
lon
,
lat
=
x
[:,
0
],
x
[:,
1
]
det
=
gm
[
5
]
*
gm
[
1
]
-
gm
[
2
]
*
gm
[
4
]
pixx
=
((
lon
-
gm
[
0
])
*
gm
[
5
]
-
(
lat
-
gm
[
3
])
*
gm
[
2
])
/
det
pixy
=
((
lat
-
gm
[
3
])
*
gm
[
1
]
-
(
lon
-
gm
[
0
])
*
gm
[
4
])
/
det
return
self
.
_data
[
pixy
.
astype
(
int
),
pixx
.
astype
(
int
)]
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