Commit 9c0963af authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Added support for GDAL virtual file systems (file paths starting with '/vsi'). Bumped version.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent be3cdb00
Pipeline #26014 passed with stages
in 2 minutes and 12 seconds
......@@ -2,6 +2,12 @@
History
=======
0.14.0 (2021-07-26)
-------------------
* Added support for GDAL virtual file systems (file paths starting with '/vsi').
0.13.4 (2021-07-13)
-------------------
......
......@@ -90,7 +90,7 @@ class GeoArray(object):
if isinstance(path_or_array, str):
assert ' ' not in path_or_array, "The given path contains whitespaces. This is not supported by GDAL."
if not os.path.exists(path_or_array):
if not os.path.exists(path_or_array) and not path_or_array.startswith('/vsi'):
raise FileNotFoundError(path_or_array)
if isinstance(path_or_array, GeoArray) or issubclass(getattr(path_or_array, '__class__'), GeoArray):
......
......@@ -147,7 +147,7 @@ class GDAL_Metadata(object):
def read_from_file(self, filePath):
assert ' ' not in filePath, "The given path contains whitespaces. This is not supported by GDAL."
if not os.path.exists(filePath):
if not os.path.exists(filePath) and not filePath.startswith('/vsi'):
raise FileNotFoundError(filePath)
ds = gdal.Open(filePath)
......
......@@ -20,5 +20,5 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
__version__ = '0.13.4'
__versionalias__ = '20210713.01'
__version__ = '0.14.0'
__versionalias__ = '20210726.01'
......@@ -28,8 +28,7 @@ test_geoarray
Tests for the geoarray.baseclasses module.
"""
import zipfile
from unittest import TestCase
import tempfile
import os
......@@ -80,6 +79,19 @@ class Test_GeoArray(TestCase):
def setUpClass(cls) -> None:
cls.gA = _get_gA_inMem_notInMem()[0][1]
def test_vsi_path(self):
os.environ['CPL_ZIP_ENCODING'] = 'UTF-8' # avoids a GDAL warning
with tempfile.TemporaryDirectory() as td:
path_zip = os.path.join(td, 'temp_archive.zip')
file_basename = os.path.basename(path_data)
with zipfile.ZipFile(path_zip, 'w') as zf:
zf.write(path_data, file_basename)
gA = GeoArray(f'/vsizip/{path_zip}/{file_basename}')
self.assertIsInstance(gA[:], np.ndarray)
@parameterized.expand(_get_gA_inMem_notInMem())
def test_bandnames(self, _, gA):
"""Test GeoArray.bandnames."""
......
Markdown is supported
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