Topics

Different values when I use a window

adrianocorbelinoii@...
 

Hello,  I've been having a problem using windows, probably a misunderstanding on my part.
My goal is to dump a specific data from a band into a csv file, first I tried to use a window but the results differ from the results that I see on Qgis(the results appear to be shifted 1 position).
So I decided to try to read the whole band, instead to use a window, and the result match with Qgis.
I think that I am doing something wrong when I create/use the window, what I tried to do was:
  1. create a window from the bounds of the desired area: 
    bandWin = rasterio.windows.from_bounds(*boundingBox,band.transform)
  2. get the transform matrix of that window:
    win_transform = band.window_transform(bandWin)
  3. Obtain the window data:
    win_data = band.read(1, window = bandWin)
  4. Get the desired window indexes:
    indexes = rasterio.transform.rowcol(win_transform, [Xs], [Ys])
  5. Get the values that I want:
    csvData.append(win_data[indexes[0],indexes[1]][0])
The only differences between when I don't use a window is that instead use win_transform I use band.transform and I read the whole band.

All help is appreciated.

adrianocorbelinoii@...
 

I am using rasterio 1.1.5.

Sean Gillies
 

Hi,

We fixed a window shift bug in 1.1.5. See


I wonder if this is another bug or if somehow your installation didn't get the fix. Can you say what your source of the rasterio package is?

On Sun, Jul 5, 2020 at 5:11 PM <adrianocorbelinoii@...> wrote:
I am using rasterio 1.1.5.



--
Sean Gillies