question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

parallel_offset returns MultiString with missing parts

See original GitHub issue

Hi,

I’m noticing strange behavior in the parallel_offset method.

Expected behavior and actual behavior.

parallel_offset should return a single LineString in the following example but returns a MultiLineString with a part missing. Works correctly for some other distances or side=‘left’ or when removing one of the points.

incorrect incorrect behavior for distance=10 correct correct behavior for distance=8

Steps to reproduce the problem.

import shapely.wkt
from matplotlib import pyplot as plt
from shapely.geometry import LineString

road = shapely.wkt.loads('LINESTRING ('
                         '424367.2267078362 4513099.023495375,'
                         ' 424370.9561004792 4513098.974304576,'
                         ' 424380.476033291 4513098.832676926,'
                         ' 424382.1039646821 4513098.816053259'
                         ')')
plt.plot(*road.coords.xy, marker='o')

line = road.parallel_offset(distance=10, side='right')

if isinstance(line, LineString):
    line = [line]

for l in line:
    plt.plot(*l.coords.xy, marker='o')

plt.gca().set_aspect('equal')
plt.show()

Operating system

Mac OS X 10.14.5

Shapely version and provenance

1.6.4.post1 installed from Conda

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Jeremiah-Englandcommented, Nov 24, 2020

A link to the ticket in the geos bug tracker: https://trac.osgeo.org/geos/ticket/806

0reactions
jorisvandenbosschecommented, Dec 3, 2022

Using the latest released shapely and GEOS versions, this is now working correctly (the offset curve implementation has been refactored):

# using example from above
road = ...

line = road.parallel_offset(distance=10, side='right')

from shapely.plotting import plot_line
plot_line(road)
plot_line(line, color="C1")

shapely_line_offset

Read more comments on GitHub >

github_iconTop Results From Across the Web

parallel_offset returns MultiString with missing parts · Issue #746
Hi,. I'm noticing strange behavior in the parallel_offset method. Expected behavior and actual behavior. parallel_offset should return a ...
Read more >
shapely parallel_offset robustness - GIS Stack Exchange
polygon.LinearRing instance Returns a LineString or MultiLineString geometry at a distance from the object on its right or its left side.
Read more >
shapely parallel_offset sometimes does not generate closed ring
I am using the parallel_offset function of the shapely package to get offset structures to some polygons that are closed rings.
Read more >
The Shapely User Manual — Shapely 2.0.0 documentation
Returns a string specifying the Geometry Type of the object in accordance with 1. >>> from shapely import Point, LineString ...
Read more >
Conduit Bending: Parallel Offsets, How to calculate ... - YouTube
In this video I show you how to find the parallel adjustment constants and how to implement them in your offsets to create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found