Commit e5b3555c authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Replaced deprecated gdalnumeric import. Bumped version.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 6ba13a29
Pipeline #35108 failed with stages
in 2 minutes and 10 seconds
......@@ -2,6 +2,12 @@
History
=======
0.15.4 (22.11.2021)
-------------------
* Replaced deprecated gdalnumeric import.
0.15.3 (11.11.2021)
-------------------
......
......@@ -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, gdalnumeric
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 = gdalnumeric.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 = gdalnumeric.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())
......
......@@ -22,5 +22,5 @@
# limitations under the License.
__version__ = '0.15.3'
__versionalias__ = '20211111.01'
__version__ = '0.15.4'
__versionalias__ = '20211122.01'
......@@ -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()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment