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

simplify with preserve_topology=True difference for MultiLineString between 3.12.1 and 3.12.2 #1127

Open
theroggy opened this issue Jul 16, 2024 · 0 comments

Comments

@theroggy
Copy link

theroggy commented Jul 16, 2024

A CI test of mine started failing for 3.12.2 versus 3.12.1, and I wondered what the correct expected behaviour is...
Reference: pygeoops/pygeoops#97

I suppose the change in behaviour is linked to this PR: #1012

There difference is in the result of simplify with preserve_topology=True for MultiLineString geometries in 3.12.2 compared to 3.12.1.

With 3.12.1, the input linestring left, the result of simplify to the right:
image

With 3.12.2, the input linestring left, the result of simplify to the right:
image

Script to reproduce:

from matplotlib import pyplot as plt
import shapely
import shapely.plotting as plotter

# Prepare test data
input_wkt = "MULTILINESTRING ((0 10, 10 10, 10 0), (10 10, 11 0, 10 0))"
input_geom = shapely.from_wkt(input_wkt)

# Simplify the input
result = shapely.simplify(input_geom, tolerance=2, preserve_topology=True)

# Plot input and result
fig, ax = plt.subplots(ncols=2)
colors = ["red", "blue"]
for index, line in enumerate(input_geom.geoms):
    plotter.plot_line(line, ax=ax[0], add_points=True, color=colors[index])
    ax[0].set_aspect("equal")
for index, line in enumerate(result.geoms):
    plotter.plot_line(line, ax=ax[1], add_points=True, color=colors[index])
    ax[1].set_aspect("equal")

plt.show()
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