Conversation
Vect_point_in_box() includes all four edges, so a point on the southern or eastern edge passed the region check, but converting it gave a row or column equal to rows or cols. The bounds check below dropped the point without a message, leaving its column unset. Bring those two edges into the last row or column, as r.what does.
Contributor
Author
|
/cc @echoix @petrasovaa |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
v.what.rastchecks every point twice, and the two checks disagree about the region edges.First it checks the box:
Vect_point_in_box()includes all four edges, so a point sitting on the southern or eastern edge passes here.Then it converts the point to a cell:
On the southern edge
rowcomes out asrows, and on the eastern edgecolcomes out ascols. Both are one past the end, so the point is thrown away here instead. There is no warning and no counter, so you never find out. The column just stays empty.r.whatalready returns a value for the same coordinate, so the two tools disagree.How I ran into it
I set the region from the points I wanted to sample, which is the normal way to use this tool:
g.regionputs the bounding box exactly on the outermost points, so my southernmost and easternmost points were dropped every time. On a small test with the region taken from a raster, four points out of seven came back empty and nothing was printed.Fix
I bring those two edges into the last row or column, the same way
r.whatdoes.The equality test is deliberate. Only a point sitting exactly on the edge converts to an index that is out of range, and anything further out is still rejected by the check below.
Tests
I added a pytest file. The expected values come from
r.whaton the same coordinates, so they are not guesses.Without the fix, the southern edge, the eastern edge, the corner and the comparison with
r.whatall fail. Interior points and the northern and western edges pass either way, and so does a point that really is outside the region.