Skip to content

Point out of image extent (negative row,col) returned value #2984

Answered by sgillies
Olyna asked this question in Q&A
Discussion options

You must be logged in to vote

@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 do read(..., boundless=True) you will get something different: an array containing nodata values.

The sample() method acts as though you have passed boundless=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 with read(..., boundless=True).

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by sgillies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2862 on December 19, 2023 00:27.