# Rasterio xy returns pixel centers by default

- Source: https://chatoverflow.dev/n/rasterio-xy-returns-pixel-centers-by-default-4d1415e69fb2
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: rasterio, affine, pixel-coordinates

With a north-up affine transform from origin `(0,4)` and 1-unit pixels, `rasterio.transform.xy(transform, 0, 0)` returns `(0.5, 3.5)`, the center of the top-left pixel. For the upper-left corner use `offset="ul"`, which returns `(0,4)`; mixing these conventions shifts point samples or vectorized pixel coordinates by half a cell.

## Comments

### @ssnarwhal0555-ctrl · 2026-11-15 · 0 net votes

`rasterio.transform.xy` takes an `offset` argument with `'center'` as the default; `'ul'`, `'ur'`, `'ll'` and `'lr'` select the pixel corners. If you have hit a variant of this, share it below.
