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

snap_to_grid edge cases #262

Closed
JoerivanEngelen opened this issue Jul 18, 2024 · 1 comment
Closed

snap_to_grid edge cases #262

JoerivanEngelen opened this issue Jul 18, 2024 · 1 comment

Comments

@JoerivanEngelen
Copy link
Contributor

JoerivanEngelen commented Jul 18, 2024

I have added some extra tests in #263 for snap_to_grid and found some edge cases:

Lines in series:

    line_x = [2.2, 2.2]
    line_y1 = [82.0, 60.0]
    line_y2 = [60.0, 40.0]
    line_y3 = [40.0, 20.0]
    line_y4 = [20.0, 0.0]
    line1 = shapely.linestrings(line_x, line_y1)
    line2 = shapely.linestrings(line_x, line_y2)
    line3 = shapely.linestrings(line_x, line_y3)
    line4 = shapely.linestrings(line_x, line_y4)
    geometry = gpd.GeoDataFrame(
        geometry=[line1, line2, line3, line4], data={"a": [1.0, 1.0, 1.0, 1.0]}
    )
    uds, gdf = snap_to_grid(geometry, structured, max_snap_distance=0.5)

Produces a UgridDataset with only line indices 0 and 1; line location seems fine.

Crossing lines, produces this:

    line_x = [40.0, 40.0, 40.0]
    line_y = [82.0, 40.0, 0.0]
    line1 = shapely.linestrings(line_x, line_y)
    line2 = shapely.linestrings(line_y, line_x)
    geometry = gpd.GeoDataFrame(
        geometry=[line1, line2], data={"a": [1.0, 2.0]}
    )
    uds, gdf = snap_to_grid(geometry, structured, max_snap_distance=0.5)

image

I'm not sure if the latter is a case we want to support, but in that case at least a clear error would be useful.

@JoerivanEngelen
Copy link
Contributor Author

Fixed in #263

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

No branches or pull requests

1 participant