kopia lustrzana https://github.com/OpenDroneMap/WebODM
Fixed plant health export for N>3 band datasets
rodzic
07ec4b0f79
commit
2af2f30a57
|
@ -16,24 +16,27 @@ def export_raster_index(input, expression, output):
|
||||||
nodata=-9999
|
nodata=-9999
|
||||||
)
|
)
|
||||||
|
|
||||||
data = src.read().astype(np.float32)
|
bands_names = ["b{}".format(b) for b in tuple(sorted(set(re.findall(r"b(?P<bands>[0-9]{1,2})", expression))))]
|
||||||
|
rgb = expression.split(",")
|
||||||
|
indexes = tuple([int(b.replace("b", "")) for b in bands_names])
|
||||||
|
|
||||||
alpha_index = None
|
alpha_index = None
|
||||||
if has_alpha_band(src):
|
if has_alpha_band(src):
|
||||||
try:
|
try:
|
||||||
alpha_index = src.colorinterp.index(ColorInterp.alpha)
|
alpha_index = src.colorinterp.index(ColorInterp.alpha)
|
||||||
|
indexes += (alpha_index, )
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
bands_names = ["b{}".format(b) for b in tuple(sorted(set(re.findall(r"b(?P<bands>[0-9]{1,2})", expression))))]
|
data = src.read(indexes=indexes, out_dtype=np.float32)
|
||||||
rgb = expression.split(",")
|
|
||||||
|
|
||||||
arr = dict(zip(bands_names, data))
|
arr = dict(zip(bands_names, data))
|
||||||
arr = np.array([np.nan_to_num(ne.evaluate(bloc.strip(), local_dict=arr)) for bloc in rgb])
|
arr = np.array([np.nan_to_num(ne.evaluate(bloc.strip(), local_dict=arr)) for bloc in rgb])
|
||||||
|
|
||||||
# Set nodata values
|
# Set nodata values
|
||||||
index_band = arr[0]
|
index_band = arr[0]
|
||||||
if alpha_index is not None:
|
if alpha_index is not None:
|
||||||
index_band[data[alpha_index] == 0] = -9999
|
# -1 is the last band = alpha
|
||||||
|
index_band[data[-1] == 0] = -9999
|
||||||
|
|
||||||
# Remove infinity values
|
# Remove infinity values
|
||||||
index_band[index_band>1e+30] = -9999
|
index_band[index_band>1e+30] = -9999
|
||||||
|
|
Ładowanie…
Reference in New Issue