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

REGR: overlay keep_geom_type issue with collections of different types #2177

Merged
merged 4 commits into from
Oct 14, 2021

Conversation

martinfleis
Copy link
Member

Fixes #2176

I still need to fabricate some tests, this is a very edge case.

@martinfleis martinfleis added this to the 0.10.2 milestone Oct 13, 2021
@jorisvandenbossche
Copy link
Member

I still need to fabricate some tests, this is a very edge case.

You can start from the existing test_keep_geom_type_geometry_collection2 I wrote:

polys1 = [
    box(0, 0, 1, 1),
    box(1, 1, 3, 3).union(box(1, 3, 5, 5)),
]

polys2 = [
    box(0, 0, 1, 1),
    box(3, 1, 4, 2).union(box(4, 1, 5, 4)),
]
df1 = GeoDataFrame({"left": [0, 1], "geometry": polys1})
df2 = GeoDataFrame({"right": [0, 1], "geometry": polys2})

this gives

ax = df1.plot()
df2.plot(ax=ax, color="red", alpha=0.5)

image

So should be relatively straightforward to adapt the box so it only touches but not overlaps?

@jorisvandenbossche
Copy link
Member

Ah, not, because if there is no overlap, the intersection also doesn't give the touching border ...

@jorisvandenbossche
Copy link
Member

Touching point instead of touching linestring (border) seems to do it:

polys1 = [
    box(0, 0, 1, 1),
    box(1, 1, 3, 3).union(box(1, 3, 5, 5)),
]

polys2 = [
    box(0, 0, 1, 1),
    box(3, 1, 5, 2).union(box(5, 1, 6, 3)),
]
df1 = GeoDataFrame({"left": [0, 1], "geometry": polys1})
df2 = GeoDataFrame({"right": [0, 1], "geometry": polys2})

and then geopandas.overlay(df1, df2, keep_geom_type=True) triggers the error.

@martinfleis
Copy link
Member Author

Ahh, I guess that while pygeos doesn't mind dissolving an array of None, shapely does...

@jorisvandenbossche jorisvandenbossche merged commit 0746be9 into geopandas:master Oct 14, 2021
@martinfleis martinfleis deleted the overlay_coll branch October 14, 2021 21:30
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

Successfully merging this pull request may close these issues.

BUG: 0.10 overlay fails where 0.9 succeeded
2 participants