Skip to content

Commit aa16ba2

Browse files
committed
Merge branch 'release/v0.1.4' of github.com:descarteslabs/descarteslabs-python into release/v0.1.4
2 parents dca3c9f + 1280ef7 commit aa16ba2

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

descarteslabs/scripts/descarteslabs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python
12
# Copyright 2017 Descartes Labs.
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,7 +13,6 @@
1213
# See the License for the specific language governing permissions and
1314
# limitations under the License.
1415

15-
#!/usr/bin/env python
1616
from __future__ import print_function
1717

1818
import os

descarteslabs/services/raster.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ def ndarray(
226226
array = npz['data']
227227
metadata = json.loads(npz['metadata'].tostring().decode('utf-8'))
228228

229-
if order == 'image':
230-
return array.transpose((1, 2, 0)), metadata
231-
elif order == 'gdal':
229+
if len(array.shape) > 2:
230+
if order == 'image':
231+
return array.transpose((1, 2, 0)), metadata
232+
elif order == 'gdal':
233+
return array, metadata
234+
else:
232235
return array, metadata

descarteslabs/tests/test_raster.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ def test_ndarray(self):
5454
except ImportError:
5555
pass
5656

57+
@unittest.skipIf(is_external_user(), "currently requires internal user")
58+
def test_ndarray_single_band(self):
59+
try:
60+
data, metadata = self.raster.ndarray(
61+
inputs=['meta_LC80270312016188_v1'],
62+
bands=['red'],
63+
resolution=960,
64+
)
65+
self.assertEqual(data.shape, (249, 245))
66+
self.assertEqual(data.dtype, np.uint16)
67+
self.assertEqual(len(metadata['bands']), 1)
68+
except ImportError:
69+
pass
70+
5771
@unittest.skipIf(is_external_user(), "currently requires internal user")
5872
def test_thumbnail(self):
5973
r = self.raster.raster(

0 commit comments

Comments
 (0)