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

[FEA] linestring-linestring intersection (pairwise) #648

Closed
3 tasks done
harrism opened this issue Aug 15, 2022 · 7 comments · Fixed by #862
Closed
3 tasks done

[FEA] linestring-linestring intersection (pairwise) #648

harrism opened this issue Aug 15, 2022 · 7 comments · Fixed by #862
Assignees
Labels
feature request New feature or request
Milestone

Comments

@harrism
Copy link
Member

harrism commented Aug 15, 2022

Is your feature request related to a problem? Please describe.

A function to return, for each specified pair of linestrings, the point at which they intersect. We may also need the segment index within each linestring of the intersection.

#648 (comment)

@harrism harrism added feature request New feature or request Needs Triage Need team to review and classify labels Aug 15, 2022
@harrism harrism moved this to Todo in cuSpatial Aug 16, 2022
@github-actions
Copy link

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

@isVoid
Copy link
Contributor

isVoid commented Oct 7, 2022

We may also need the segment index within each linestring of the intersection.

Can you confirm?

@harrism
Copy link
Member Author

harrism commented Oct 7, 2022

Based on the recent meeting I believe the answer is yes.

@isVoid
Copy link
Contributor

isVoid commented Oct 8, 2022

Linestring intersections can return not only points, but also linestrings. This happens when two linestrings overlaps. Based on this, the return result of intersecting two linestrings could be not just points, but also linestrings.

Another challenge is that linestring can have multiple intersections per pair. We can use a geometry collection to store the result, e.g. MultiPoint for point intersections and MultiLinestring for multiple linestring overlaps.

To sum up, the result for each row can have at most one MultiPoint and one MultiLineString. Thus the result can be stored in a pair of MultiPoint and MultiLineString array. With the following indices arrays for both the lhs and rhs inputs:

point_geometry_idx: list of idx, the `j`th element in the `i`th row of the series indicates the multilinestring idx on lhs/rhs of the `j`th intersecting point of the `ith` pair.
linestring_geometry_idx: list of idx, the `j`th element in the `i`th row of the series indicates the multilinestring idx on lhs/rhs of the `j`th overlapping linestring of the `ith` pair.
point_part_idx: list of idx, the `j`th element in the `i`th row of the series indicates the segment idx on lhs/rhs of the `j`th intersecting point of the `ith` pair.
linestring_part_idx: list of idx, the `j`th element in the `i`th row of the series indicates the segment idx on lhs/rhs of the `j`th overlapping linestring of the `ith` pair.

@isVoid isVoid added this to the DE-9IM milestone Oct 10, 2022
@harrism
Copy link
Member Author

harrism commented Oct 11, 2022

point_geometry_idx: list of idx, the jth element in the ith row of the series indicates the multilinestring idx on lhs/rhs of the jth intersecting point of the ith pair.
linestring_geometry_idx: list of idx, the jth element in the ith row of the series indicates the multilinestring idx on lhs/rhs of the jth overlapping linestring of the ith pair.
point_part_idx: list of idx, the jth element in the ith row of the series indicates the segment idx on lhs/rhs of the jth intersecting point of the ith pair.
linestring_part_idx: list of idx, the jth element in the ith row of the series indicates the segment idx on lhs/rhs of the jth overlapping linestring of the ith pair.

Oooh, that's confusing... Perhaps we can encapsulate it somehow.

@thomcom
Copy link
Contributor

thomcom commented Oct 11, 2022

This is probably why GeoPandas and Shapely just return the objects that are in the intersection, right? We don't want users to have to reconstruct their dataset from indices and etc, maybe we can reorganize the data on the way back to become a new set of union_offsets and union_types that represent the intersection using the original input data?

@isVoid
Copy link
Contributor

isVoid commented Oct 14, 2022

using the original input data?

Intersection primitive may create new data that does not belong to original input data. I was thinking of using union column type to encapsulate the intersecting-point/overlapping-linestrings. At best it can encapsulate the mixed geometry types (thereby eliminating the need of using two separate column for point and linestring).

Subsequently, the union column style can help reduce the number indices columns by half.

@harrism harrism moved this from Todo to In Progress in cuSpatial Oct 24, 2022
@jarmak-nv jarmak-nv removed the Needs Triage Need team to review and classify label Feb 15, 2023
@jarmak-nv jarmak-nv moved this from In Progress to Review in cuSpatial Feb 27, 2023
@jarmak-nv jarmak-nv moved this from Review to Blocked in cuSpatial Feb 27, 2023
@rapids-bot rapids-bot bot closed this as completed in #862 Feb 27, 2023
rapids-bot bot pushed a commit that referenced this issue Feb 27, 2023
…on` (#862)

This PR adds column/python API for `pairwise_linestring_intersection`. Closes #648 

This PR is also the first attempt of #261 , establishing `geometry_column_view` that inherits `cudf::column` and adds additional information to identify the underlying nested levels. Note that it cannot directly inherit from `cudf::lists::list_column_view`, because a point array isn't a `List<T>` array.

Also note that the type codes defined in libcuspatial and cuspatial-python may be different, so there is a type code mapping after computing the result from libcuspaital.

Finally, since `List<Union>` is currently unsupported in libcudf, the python API returns the geometries in two parts: `offset + GeoColumn`.

Authors:
  - Michael Wang (https://github.com/isVoid)

Approvers:
  - H. Thomson Comer (https://github.com/thomcom)
  - Mark Harris (https://github.com/harrism)

URL: #862
@github-project-automation github-project-automation bot moved this from Blocked to Done in cuSpatial Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants