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

Track CRS info in BoundingBox and changes to GeoBox constructors #38

Merged
merged 9 commits into from Apr 27, 2022

Conversation

Kirill888
Copy link
Member

@Kirill888 Kirill888 commented Apr 22, 2022

  1. BoundingBox was an odd one out without CRS info attached, now it has that

    • This enables other conveniences, two way conversion polygon<->bbox
  2. Changes to GeoBox.from_bbox

    • Can get CRS info directly from bounding box now
    • Replace confusing "align" that is pretty hard to explain with "anchor"

Essentially if you take 0,0 in the real world, bring it to pixel space and locate pixel that contains it, then you want location within that pixel to be a certain point in [0, 1), [0, 1), so 0,0 is edge aligned, same as align=(0,0) used to be, and to get center aligned pixel you pick (0.5, 0.5). Also you can just not align at all, in which case resulted geobox will start at left,top and might go a little bit over right, bottom.

Also adds some more convenience methods to bounding box and geobox.

Closes #25

Adding .crs property to BoundingBox class, it no longer derives from
namedtuple so there is some potential for breakage compared to what's
in datacube-core.
.from_transform - construct from shape+affine
.polygon return geometry from bbox
compute footprint of geobox in any projection with
configurable padding and precision
`align=` was too confusing and hard to document, concept of anchor I
feel is more reasonable. You can anchor pixel edges to 0,0 or pixel
center to 0,0, or you can leave it floating. Or you can pick any
location within a pixel and say that 0,0 should coincide with that.

center == (0.5, 0.5)
edge == (0, 0)

Also replacing _align_pix methods, that were hard to decipher, with
snap_grid method in odc.geo.math
@Kirill888 Kirill888 requested a review from gadomski April 22, 2022 11:21
@codecov
Copy link

codecov bot commented Apr 22, 2022

Codecov Report

Merging #38 (8094832) into develop (de7f414) will increase coverage by 0.07%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop      #38      +/-   ##
===========================================
+ Coverage    97.91%   97.99%   +0.07%     
===========================================
  Files           19       19              
  Lines         2595     2690      +95     
===========================================
+ Hits          2541     2636      +95     
  Misses          54       54              
Impacted Files Coverage Δ
odc/geo/geobox.py 100.00% <100.00%> (ø)
odc/geo/geom.py 100.00% <100.00%> (ø)
odc/geo/gridspec.py 100.00% <100.00%> (ø)
odc/geo/math.py 100.00% <100.00%> (ø)
odc/geo/overlap.py 100.00% <100.00%> (ø)
odc/geo/roi.py 100.00% <100.00%> (ø)
odc/geo/types.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de7f414...8094832. Read the comment docs.

@github-actions
Copy link

@github-actions
Copy link

@github-actions
Copy link

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 this pull request may close these issues.

API: better bounding box
2 participants