-
Expected behavior and actual behavior.Compare 3 different implementations to read
Both points and raster should have the same Coordinate Reference System. Points Implementation 1: Steps to reproduce the problem.Data Implemented functions
Environment Information
Installation Methodconda 4.10.3 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Regarding the usage of https://github.com/rasterio/rasterio/blob/main/rasterio/sample.py# If the coordinate is out of bounds, then the dataset's nodata or 0 is used as the return value. That could explain why you are getting 0. What is the dataset's nodata value? I'll have to look deeper to understand what is going on with the other rasterio implementation. |
Beta Was this translation helpful? Give feedback.
-
@Olyna thank you for bringing this question! Rasterio's The If I've read your description correctly, what you observe is to be expected. |
Beta Was this translation helpful? Give feedback.
@Olyna thank you for bringing this question!
Rasterio's
read()
is intended to behave like numpy array slicing. Think of a window as a pair of slice objects. When the window is outside the raster indexes, rasterio returns an empty array. Now, if you doread(..., boundless=True)
you will get something different: an array containing nodata values.The
sample()
method acts as though you have passedboundless=True
. Thus, you should get nodata values for points outside the raster.If I've read your description correctly, what you observe is to be expected.
sample()
is consistent withread(..., boundless=True)
.