Sweet! Thank you. I was struggling for an embarrassing amount of time with this.
Since it’s a First Steps post, here’s the whole thing.
function read_dat(filename, dims, T)
img = Array{T}(undef, (dims))
open(filename) do io
read!(io, img)
end
end
> data = read_dat("myfilename.img", (251, 260), Float32)
251x260 Array{Float32,2}:...
Though I’m not sure how to pass the dims. This doesn’t work:
bands=250; lines=260; samples=440;
fn = “myfile.img”;
dtype = Float32;
data = read_dat(fn, (bands,lines,samples), dtype)
Tried a few variations; ([b,l,s]), ((b,s,l))… ???