Skip to content

point_query does not always return a value for coordinates at the corner of a pixel bordered by no-data #294

@Frederic-gci

Description

@Frederic-gci

Describe the bug
When querying a raster for coordinates that are at the corner of a pixel limited by no-data, I expect to retrieve some data for every corner, but in 3/4 cases, None is returned.

To Reproduce
This happened to me querying a large raster in EPSG:32188 projection for coordinates that are bordering no-data pixels. Here is a minimal example:

import numpy as np
from rasterio.transform import Affine
from rasterstats import point_query
from shapely.geometry import Point

data = np.array([[0,0,0],[0,1,0], [0,0,0]])
transform = Affine(1, 0, 0, 0, -1, 3)
points = [Point(1, 1), Point(2, 1), Point(1, 2), Point(2, 2)]
print(point_query(points, data, affine=transform, interpolate='nearest', nodata=0))
print(point_query(points, data, affine=transform, interpolate='bilinear', nodata=0))

rasterstats version is 0.19.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions