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

[BUG] .x and .y accessors do not reflect previous slicing. #683

Closed
thomcom opened this issue Sep 20, 2022 · 0 comments · Fixed by #685
Closed

[BUG] .x and .y accessors do not reflect previous slicing. #683

thomcom opened this issue Sep 20, 2022 · 0 comments · Fixed by #685
Labels
bug Something isn't working

Comments

@thomcom
Copy link
Contributor

thomcom commented Sep 20, 2022

Describe the bug
When you slice a GeoSeries, the Union indexing only leaves offsets for the sliced members, but the underlying point and sub-offsets are not modified or copied. However, if you then later use a coordinate accessor like sliced.polygons.x, the .x accessor doesn't understand that the offsets have changed and returns the same indices regardless of which slice you are calling it on.

Steps/Code to reproduce bug

host_dataframe = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres"))
gpu_dataframe = cuspatial.from_geopandas(host_dataframe)
polygons_first = gpu_dataframe['geometry'][0:10]
polygons_second = gpu_dataframe['geometry'][10:20]
cuspatial.core.spatial.distance.haversine_distance(
    polygons_first.polygons.x,
    polygons_first.polygons.y,
    polygons_second.polygons.x,
    polygons_second.polygons.y
)
print(polygons_first.polygons.x.head())
print(polygons_second.polygons.x.head())
0    180.000000
1    180.000000
2    179.364143
3    178.725059
4    178.596839
dtype: float64
0    180.000000
1    180.000000
2    179.364143
3    178.725059
4    178.596839

Expected behavior
The result of the two print results should be different .x values, reflecting different polygons.

@thomcom thomcom added bug Something isn't working Needs Triage Need team to review and classify labels Sep 20, 2022
@rapids-bot rapids-bot bot closed this as completed in #685 Sep 23, 2022
rapids-bot bot pushed a commit that referenced this issue Sep 23, 2022
…`.polygons` `GeoSeries` accessors (#685)

This PR uses the `column._meta` object to slice the sub-geometry accessors named in the title so that `.x`, `.y`, and `.xy` uses reflect any previous slicing that has occurred to the `GeoSeries`.

Fixes #683

Authors:
  - H. Thomson Comer (https://github.com/thomcom)

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

URL: #685
@harrism harrism removed the Needs Triage Need team to review and classify label Sep 26, 2022
@harrism harrism moved this to Done in cuSpatial Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
2 participants