Skip to content

RS_ZonalStats line rois: all_touched is ignored, and the default rule burns every traversed cell #3322

Description

@james-willis

Probing RS_ZonalStats with LINESTRING rois on a 20x20 unit-pixel grid (the GH-3118 RasterizationTests fixtures) against GDAL/rasterio ground truth shows two line-specific behaviors in the rasterization path:

  1. all_touched=true is ignored for line geometries. The count never changes with the flag; cells that the segment's envelope touches but does not cross are never included. GDAL/rasterio all_touched=True includes them.

    segment default all_touched (Sedona) all_touched (GDAL/rasterio)
    LINESTRING (1.5 2.75, 10.5 7.25) 10 10 15
    LINESTRING (0.75 1.25, 4.25 11.75) 11 11 15
    LINESTRING (2.5 2.5, 9.5 9.5) 8 8 15
  2. The default (no all_touched) line rule burns every traversed cell. GDAL's default line rasterization uses the centre/diamond crossing rule, which burns fewer: e.g. LINESTRING (1.3 2.7, 8.6 11.4) burns 17 cells in Sedona but 10 in GDAL/rasterio. (Corner-crossing segments mask this — their traversal and diamond counts coincide, which is why the Line rasterization uses fixed-step sampling instead of exact cell traversal, dropping boundary pixels (allTouched and LINESTRING) #3118 fixtures agree by default.)

Together these mean a line roi's zonal statistics differ from GDAL-based engines in both flag positions. Surfaced by the SedonaDB↔Sedona Spark parity suite (apache/sedona-db integration/spark-parity), where SedonaDB (GDAL rasterizer) matches rasterio in all four regimes.

GH-3118's direction-independence itself holds in every probed case (forward and reversed WKTs agree), as does the polygon path (the coastline fixture's pinned 1738/1842 counts match exactly).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions