Skip to content

Commit 5a6b306

Browse files
committed
add band number and band indices as optional config arguments
1 parent 37eeeb5 commit 5a6b306

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

docs/parameters.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,10 @@ Here is the full list of configuration parameters you can specify in a ``config.
7272

7373
**over_zoom**: int
7474
An integer greater than 0. If set for XYZ tiles, it will fetch tiles from `zoom` + `over_zoom`, to create higher resolution tiles which fill out the bounds of the original zoom level.
75+
76+
**band_count**: int
77+
An integret greater than 1. If not specified defaults to 3 for the typical r,g,b imagery.
78+
79+
**band_indicies**: tuple
80+
A tuple of band incidies to pull from a tiff. Defaults to (1, 2, 3) if not specified. For using non-RGB tifs, ie MS tifs this should be over-written
81+
for example to (5, 3, 2, 7) to extract Red, Green, Blue, and NIR bands from the MS spacenet imagery.

label_maker/utils.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,21 @@ def get_tile_tif(tile, imagery, folder, kwargs):
137137
window = ((top, bottom), (left, right))
138138

139139
# read the first three bands (assumed RGB) of the TIF into an array
140-
data = np.empty(shape=(3, 256, 256)).astype(src.profile['dtype'])
141-
for k in (1, 2, 3):
140+
141+
try:
142+
kwargs['band_count']
143+
band_count = kwargs['band_count']
144+
except KeyError:
145+
band_count = 3
146+
147+
try:
148+
kwargs['band_indicies']
149+
band_count = kwargs['band_indicies']
150+
except KeyError:
151+
band_indicies = (1, 2, 3)
152+
153+
data = np.empty(shape=(band_count, 256, 256)).astype(src.profile['dtype'])
154+
for k in band_indicies:
142155
src.read(k, window=window, out=data[k - 1], boundless=True)
143156

144157
# save

label_maker/validate.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@
3535
'split_vals': {'type': 'list', 'schema': {'type': 'float'}},
3636
'split_names': {'type': 'list', 'schema': {'type': 'string'}},
3737
'tms_image_format': {'type': 'string'},
38-
'over_zoom': {'type': 'integer', 'min': 1}
38+
'over_zoom': {'type': 'integer', 'min': 1},
39+
'band_count': {'type': 'integer', 'min': 1},
40+
'band_indicies': {'type': 'tuple'}
3941
}

0 commit comments

Comments
 (0)