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
Daniel Scheffler
geoarray
Commits
e5b3555c
Commit
e5b3555c
authored
Nov 22, 2021
by
Daniel Scheffler
Browse files
Replaced deprecated gdalnumeric import. Bumped version.
Signed-off-by:
Daniel Scheffler
<
danschef@gfz-potsdam.de
>
parent
6ba13a29
Pipeline
#35108
failed with stages
in 2 minutes and 10 seconds
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
HISTORY.rst
View file @
e5b3555c
...
...
@@ -2,6 +2,12 @@
History
=======
0.15.4 (22.11.2021)
-------------------
* Replaced deprecated gdalnumeric import.
0.15.3 (11.11.2021)
-------------------
...
...
geoarray/baseclasses.py
View file @
e5b3555c
...
...
@@ -32,7 +32,7 @@ from copy import copy, deepcopy
from
typing
import
Union
,
Optional
# noqa F401
import
numpy
as
np
from
osgeo
import
gdal
,
gdal_array
,
gdal
numeric
from
osgeo
import
gdal
,
gdal_array
,
gdal
_array
from
shapely.geometry
import
Polygon
from
shapely.wkt
import
loads
as
shply_loads
# dill -> imported when dumping GeoArray
...
...
@@ -956,7 +956,7 @@ class GeoArray(object):
# TODO insert a multiprocessing.Lock here in order to prevent IO bottlenecks?
# read subset area from disk
if
bL
==
list
(
range
(
0
,
B
)):
tempArr
=
gdal
numeric
.
LoadFile
(
path
,
cS
,
rS
,
cE
-
cS
+
1
,
rE
-
rS
+
1
)
tempArr
=
gdal
_array
.
LoadFile
(
path
,
cS
,
rS
,
cE
-
cS
+
1
,
rE
-
rS
+
1
)
out_arr
=
np
.
swapaxes
(
np
.
swapaxes
(
tempArr
,
0
,
2
),
0
,
1
)
if
B
>
1
else
tempArr
if
out_arr
is
None
:
raise
Exception
(
'Error reading file: '
+
gdal
.
GetLastErrorMsg
())
...
...
@@ -1938,7 +1938,7 @@ class GeoArray(object):
def
get_GeoArray_from_GDAL_ds
(
ds
):
# TODO implement as class method of GeoArray
arr
=
gdal
numeric
.
DatasetReadAsArray
(
ds
)
arr
=
gdal
_array
.
DatasetReadAsArray
(
ds
)
if
len
(
arr
.
shape
)
==
3
:
arr
=
np
.
swapaxes
(
np
.
swapaxes
(
arr
,
0
,
2
),
0
,
1
)
return
GeoArray
(
arr
,
ds
.
GetGeoTransform
(),
ds
.
GetProjection
())
...
...
geoarray/version.py
View file @
e5b3555c
...
...
@@ -22,5 +22,5 @@
# limitations under the License.
__version__
=
'0.15.
3
'
__versionalias__
=
'202111
11
.01'
__version__
=
'0.15.
4
'
__versionalias__
=
'202111
22
.01'
tests/test_geoarray.py
View file @
e5b3555c
...
...
@@ -533,6 +533,22 @@ class Test_GeoArray(TestCase):
self
.
assertFalse
(
diff
)
# os.system(f'gdalinfo {p_out}')
def
test_save_meta_GTiff_compress
(
self
):
gA
=
_get_gA_inMem_notInMem
(
path_subset_tif
)[
0
][
1
]
with
TemporaryDirectory
(
prefix
=
'geoarray__'
)
as
td
:
p_out
=
os
.
path
.
join
(
td
,
'outfile.tif'
)
gA
.
save
(
p_out
,
fmt
=
'GTiff'
,
creationOptions
=
[
'COMPRESS=DEFLATE'
])
# compare gdalinfo output
gdalinfo_out
=
[
i
+
'
\n
'
for
i
in
getoutput
(
f
'gdalinfo
{
p_out
}
'
).
split
(
'
\n
'
)]
gdalinfo_orig
=
[
i
+
'
\n
'
for
i
in
getoutput
(
f
'gdalinfo
{
path_subset_tif
}
'
).
split
(
'
\n
'
)]
diff
=
''
.
join
(
list
(
unified_diff
(
gdalinfo_orig
[
2
:],
gdalinfo_out
[
2
:])))
self
.
assertFalse
(
diff
)
# os.system(f'gdalinfo {p_out}')
def
test_show
(
self
):
# test 3D case
self
.
gA
.
show
()
...
...
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