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

compute_reproject_roi incorrect behaviour for non-overlapping geoboxes #647

Closed
Kirill888 opened this issue Feb 6, 2019 · 1 comment · Fixed by #648
Closed

compute_reproject_roi incorrect behaviour for non-overlapping geoboxes #647

Kirill888 opened this issue Feb 6, 2019 · 1 comment · Fixed by #648

Comments

@Kirill888
Copy link
Member

Expected behaviour

When src and dst do no overlap I expect both src_roi and dst_roi to be empty on output. Seems like in some cases one can get empty src_roi while dst_roi isn't empty.

See user report here: opendatacube/datacube-stats#173

@Kirill888
Copy link
Member Author

Problem is in this function:

def compute_roi(src, dst, tr, pts_per_side, padding, align):
XY = np.vstack(tr.back(gbox_boundary(dst, pts_per_side)))
roi_src = roi_from_points(XY, src.shape, padding, align=align)
# project src roi back into dst and compute roi from that
xy = np.vstack(tr(roi_boundary(roi_src, pts_per_side)))
roi_dst = roi_from_points(xy, dst.shape, padding=0) # no need to add padding twice
return (roi_src, roi_dst)

On line 602 roi_src can be empty, say it's a vertical line with zero width, but non-zero height. After projecting back to dst coordinate reference (line 605) vertical line becomes a slightly angled line, and so bounding box of that line is no longer zero width. So this explains how empty source roi can still result in non-empty dst roi.

The fix is to short circuit computation soon after line 602 and set dst_roi to some empty value like r_[0:0,0:0].

Kirill888 added a commit that referenced this issue Feb 7, 2019
Slightly touching but non-overlapping geoboxes might result in roi_dst being
non-empty even though roi_src is.
Kirill888 added a commit that referenced this issue Feb 7, 2019
Slightly touching but non-overlapping geoboxes might result in roi_dst being
non-empty even though roi_src is.
Kirill888 added a commit that referenced this issue Feb 7, 2019
check if src_roi is empty before projecting it to dst
@mergify mergify bot closed this as completed in #648 Feb 7, 2019
mergify bot pushed a commit that referenced this issue Feb 7, 2019
Slightly touching but non-overlapping geoboxes might result in roi_dst being
non-empty even though roi_src is.
mergify bot pushed a commit that referenced this issue Feb 7, 2019
check if src_roi is empty before projecting it to dst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant