-
Notifications
You must be signed in to change notification settings - Fork 41
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 conversion between cf and shapely for lines #460
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #460 +/- ##
==========================================
+ Coverage 83.10% 83.26% +0.15%
==========================================
Files 14 14
Lines 2676 2749 +73
Branches 189 199 +10
==========================================
+ Hits 2224 2289 +65
- Misses 402 409 +7
- Partials 50 51 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Thanks! This is great to see cc @aulemahal |
Just to make sure this is visible from this side as well: while working on this PR I was pointed to https://github.com/twhiteaker/CFGeom. I have opened an issue on that repo to see if the contributors over there have opinions about how these efforts relate to each other. |
cf_xarray/tests/test_geometry.py
Outdated
[0, 2, 4, 6, 0, 0, 1, 1.0, 2.0, 9.5], dims=("node",), attrs={"axis": "Y"} | ||
), | ||
part_node_count=xr.DataArray([4, 3, 3], dims=("index",)), | ||
node_count=xr.DataArray([2, 2, 3, 3], dims=("counter",)), |
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 part caught me up for a bit. As I understand it, the node_count
is the number of nodes per line segment. So each line segment in a multiline results in a value in this array. This means that the dims is not index
and is not in the shapely version at all. I gave it a kind of random name counter
which should probably be changed.
@jsignell Any interest in picking this back up? |
This could be significantly simplified by using |
The motivation for this work was to support IO in xvec, so I kind of stalled after @martinfleis came up with a better solution on that side. If there is still desire for this work then sure I can pick it back up. |
@jsignell if you mean the WKB option, there is a bit of disagreement if that is a good idea. If we can get conversion to CF geometries via ragged array IO shapely has, we can use practically the same for GeoArrow option and Zarr (if we decide that is what we want). I still like the elegance of WKB but understand that some folks don't like saving binary objects into Zarr. |
Ah yeah I did mean the WKB option. In that case I can pick this back up. Or @dcherian feel free to take it over if you have some urgency around it. |
Thanks for the tip @martinfleis! I looked into I think the complexity in this PR comes from how cf intermingles MULTILINESTRING and LINESTRING. So once you have the line segments you still need to figure out which of them are going to be MULTILINESTRING objects. That is basically what the entirety this section is doing: https://github.com/xarray-contrib/cf-xarray/pull/460/files#diff-6484364cf7fa3216828551b2531094b30d77cf393313226a01d425c22580688aR353-R370 That is probably not the best possible way to do that conversion but I don't see anything similar in the |
Ok I added the shapely to CF direction for that one I found it pretty straightforward to use |
Ok this is clearly a case of Monday brain > Friday brain. |
I'm going to see what I can do to fix CI and improve coverage. |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
I can't really review this so I'm happy to merge when you're ready. |
I'll do the review, it is on my to-do list with an increasing priority :D. |
Yeah it's finally green and fairly well tested so it is actually ready for review for the first time 😅 |
Thanks @jsignell . We can address @martinfleis comments as they come in :) |
YOLO! |
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.
Approved (even if too late)! Looks good @jsignell!
I suppose that Polygons will look similar but we'll need to deal with holes as one layer on top of this.
Yeah I will probably start on that one now with all this fresh in my head. Also I don't think I really considered z, so that might be something to look out for. |
Thanks for taking a look @martinfleis 🙏 |
I started on this at the SciPy sprints with the idea of pushing forward the work described in this ticket: xarray-contrib/xvec#48. It took me a while to get the logic right 😅 so I wanted to make sure it was somewhere public in case I don't get a chance to come back to it in the near future.