Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Frederic-gci opened this issue Oct 12, 2023 · 0 comments
Labels

Comments

@Frederic-gci
Copy link

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

@perrygeo perrygeo added the bug label Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants