Skip to content

Clarify text around transform origin being top-left corner #13

@kylebarron

Description

@kylebarron

In geospatial data, the index (0, 0) tends to be at the top-left corner of the image, but unless we put additional restrictions on the format of spatial:transform, this is not necessarily true.

I think we should probably update the text to say (0, 0) is normally the top-left corner but isn't required by the spec.

spatial/README.md

Lines 148 to 161 in 59dd7f4

- `a`: pixel width (w-e pixel resolution)
- `b`: row rotation (typically 0)
- `c`: x-coordinate of the upper-left corner of the upper-left pixel
- `d`: column rotation (typically 0)
- `e`: pixel height (n-s pixel resolution, negative value for north-up images)
- `f`: y-coordinate of the upper-left corner of the upper-left pixel
**Coordinate convention:**
The transform operates on array indices where `(0, 0)` is at the **top-left corner** of the top-left pixel, and `(width, height)` is at the bottom-right corner of the bottom-right pixel. The center of the top-left pixel is at `(0.5, 0.5)`.
This follows the GDAL geotransform and Python's Affine library convention.
Note: Rasterio's `xy()` and `rowcol()` methods automatically add/subtract 0.5 to convert between pixel coordinates and corner coordinates. For example, `transformer.xy(0, 0)` is equivalent to applying this transform to `(0.5, 0.5)`, giving the coordinate at the center of the first pixel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions