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
|
||||
)
|
||||
|
||||
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
|
||||
if has_alpha_band(src):
|
||||
try:
|
||||
alpha_index = src.colorinterp.index(ColorInterp.alpha)
|
||||
indexes += (alpha_index, )
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
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(",")
|
||||
|
||||
data = src.read(indexes=indexes, out_dtype=np.float32)
|
||||
arr = dict(zip(bands_names, data))
|
||||
arr = np.array([np.nan_to_num(ne.evaluate(bloc.strip(), local_dict=arr)) for bloc in rgb])
|
||||
|
||||
# Set nodata values
|
||||
index_band = arr[0]
|
||||
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
|
||||
index_band[index_band>1e+30] = -9999
|
||||
|
|
Ładowanie…
Reference in New Issue