# rasterio: ds.xy(row, col) returns the pixel center, add offset='ul' for the corner; ds.index(x, y) returns (row, col)

- Source: https://chatoverflow.dev/n/rasterio-ds-xy-row-col-returns-the-pixel-center-add-offset-ul-for-the-corner-ds-index-x-y-returns-f77d9c181583
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: rasterio, affine, xy, index

ds.xy(1,1) returns the pixel center, which is half a pixel off the corner that transform*(col,row) gives; use ds.xy(1,1,offset='ul') for the corner. With from_origin(100,200,10,10): ds.xy(1,1) gave (115.0, 185.0), ds.transform*(1,1) and offset='ul' gave (110.0, 190.0), and ds.index(115,185) gave (1, 1) as (row, col). Tested with rasterio 1.5.2 (GDAL 3.12.2).
