Skip to content

Commit 4b8f9a1

Browse files
committed
remove band count from config and determin it from band indicies
1 parent 609ac16 commit 4b8f9a1

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

docs/parameters.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ Here is the full list of configuration parameters you can specify in a ``config.
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.
7575

76-
**band_count**: int
77-
An integret greater than 1. If not specified defaults to 3 for the typical r,g,b imagery.
78-
7976
**band_indicies**: list
80-
A list 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.
77+
A list 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
78+
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: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,24 +138,21 @@ def get_tile_tif(tile, imagery, folder, kwargs):
138138
window = ((top, bottom), (left, right))
139139

140140
# read the first three bands (assumed RGB) of the TIF into an array
141-
142-
try:
143-
kwargs['band_count']
144-
band_count = kwargs['band_count']
145-
except KeyError:
146-
band_count = 3
147141
try:
148142
kwargs['band_indicies']
149143
band_indicies = tuple(kwargs['band_indicies'])
144+
band_count = len(kwargs['band_indicies'])
150145
except KeyError:
151146
band_indicies = (1, 2, 3)
147+
band_count = 3
152148

153149
arr_shape = tuple([band_count, 256, 256])
154150
data = np.empty(shape=(arr_shape)).astype(src.profile['dtype'])
151+
155152
for i, k in enumerate(band_indicies):
156153
src.read(k, window=window, out=data[i], boundless=True)
157154
# save
158-
if band_indicies == (1, 2, 3) and band_count == 3:
155+
if band_indicies == (1, 2, 3):
159156
tile_img = op.join(folder, '{}{}'.format(tile, '.jpg'))
160157
img = Image.fromarray(np.moveaxis(data, 0, -1))
161158
img.save(tile_img)

label_maker/validate.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
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},
39-
'band_count': {'type': 'integer', 'min': 1},
38+
'over_zoom': {'type': 'integer', 'min': 1},
4039
'band_indicies': {'type': 'list'}
4140
}

test/fixtures/integration/config.integration.bands.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
"imagery": "integration-ms/ms-img.tif",
99
"background_ratio": 0,
1010
"ml_type": "classification",
11-
"band_count": 2,
1211
"band_indicies": [5, 7]
1312
}

0 commit comments

Comments
 (0)