Skip to content

AutoRIFT assumes single-band optical data by default (?) #108

@ehultee

Description

@ehultee

Hi there!

I am playing with some drone data and hoping to run it through autoRIFT for velocities. It is optical data with 4 bands, saved by rasterio with shape (4, 30921, 36965). I am getting an error that suggests AutoRIFT is not expecting this structure:

>> python testautoRIFT.py -m tif1_CommonSample.tif -s tif2_CommonSample.tif -fo 1

/Users/eultee/miniforge3/envs/arift/lib/python3.12/site-packages/osgeo/gdal.py:311: FutureWarning: Neither gdal.UseExceptions() nor gdal.DontUseExceptions() has been explicitly called. In GDAL 4.0, exceptions will be enabled by default.
  warnings.warn(
Preprocessing filter width 5
Using preprocessing methods ['hps', 'hps']
Setting Wallis Filter Width to 5
Traceback (most recent call last):
  File "/Users/eultee/Documents/GitHub/autoRIFT/testautoRIFT.py", line 1137, in <module>
    main()
  File "/Users/eultee/Documents/GitHub/autoRIFT/testautoRIFT.py", line 411, in main
    generateAutoriftProduct(indir_m=inps.indir_m, indir_s=inps.indir_s, grid_location=inps.grid_location,
  File "/Users/eultee/Documents/GitHub/autoRIFT/testautoRIFT.py", line 545, in generateAutoriftProduct
    runAutorift(
  File "/Users/eultee/Documents/GitHub/autoRIFT/testautoRIFT.py", line 188, in runAutorift
    m,n = obj.I1.shape
    ^^^
ValueError: too many values to unpack (expected 2)

When I read I1 using GDAL's ReadAsArray, its shape is (4, 30921, 36965) -- as I would expect. But it appears that loadProductOptical expects the output of read as array to have shape (m,n) rather than (nbands, m, n).

One fix I can think of is to apply loadProductOptical to read in each band of my data (e.g. using GDAL’s band=DS.GetRasterBand(1)) instead of the whole image. But then I suppose I have to loop over all the bands, and somehow reassemble them? I see that other functions in autoRIFT are aware of bands.

I am not very experienced in this level of RS processing, so if there’s a usual community practice I’m missing here, I’m happy to hear about it (and sorry to raise an issue in that case!). And if I happen to find a workaround with loadProductOptical, I'll report back. Happy for other thoughts in the meantime!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions