-
Notifications
You must be signed in to change notification settings - Fork 175
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
Add support for gridspec origin convention #158
Conversation
Ooops -- I pushed over the 1000 line/module limit:
|
Coverage increased (+0.02%) to 79.492% when pulling 5d8aa289828665c69fba00f13b1fa9964b4b36dc on ceholden:develop into dddd3f7 on data-cube:develop. |
I think the tile pixel coordinates (GeoBox) are not calculated correctly. I'm also wandering if the conventions can be controlled with a sign on |
@v0lat1le I have some initial work toward specifying upper-left via a negative y/latitude in |
Coverage decreased (-0.1%) to 79.364% when pulling 4eac0f933b3d18238dd16665317dccc1bf47db1c on ceholden:develop into 8b00217 on data-cube:develop. |
Coverage decreased (-0.1%) to 79.364% when pulling 4eac0f933b3d18238dd16665317dccc1bf47db1c on ceholden:develop into 8b00217 on data-cube:develop. |
@@ -718,8 +718,11 @@ def grid_range(lower, upper, step): | |||
>>> list(GridSpec.grid_range(1.0, 4.0, 3.0)) | |||
[0, 1] | |||
""" | |||
assert step > 0.0 | |||
return range(int(math.floor(lower / step)), int(math.ceil(upper / step))) | |||
assert abs(step) > 0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assert fails:
assert list(GridSpec.grid_range(1.0, 4.0, -3.0)) == [-2, -1]
Having something like this an the top of the function should do the trick:
if step < 0.0:
lower, upper, step = -upper, -lower, -step
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's much smarter than what I was doing. New commit adds that example in doctest format and I switched to the implementation you suggested.
Negative y dimension for tile_size combined with origin specified for upper-left allows tile indexes to be consistent with other grid specifications like WELD or MODIS
I finally got back around to this again and implemented the change as was suggested in the PR review. The examples I added specific to WELD's grid in the tests and the |
This addition follows the addition of
origin
to theGridSpec
configuration in helping to make tiled data output from the ingestion compatible with existing gridded data. Theorigin
specification allows the data to co-align and this proposed change would also allow the tile indexes to be identical by allowing users to count indexes relative to an upper left instead of the current bottom left. My interest in this change comes from wanting our tiled data to be in line with data from the Landsat WELD project grid specification (which IIRC is also being used for the USGS LCMAP project).I've added a test that was validated against the WELD tile lookup calculator, and I've also run an ingest with the proposed changes. The tile indices created from this ingest run using
convention = "upperleft"
match and since theorigin
addition the tiles also coalign. The current "convention" of counting from the bottom left is still default and I don't think I've affected any calculations for that case.Happy to iterate on any aspect of this with you all. Thanks!