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.

Unexpected behavior of buffer with LinearRing object

See original GitHub issue

Expected behavior and actual behavior.

Maybe I’m using the LinearRing in an unsupported fashion, but when I use LinearRing.buffer I get more vertices than expected around the first (identical to the last since it’s a ring) input vertex.

Steps to reproduce the problem.

# define an equilateral triangle as LinearRing (just to make sure than all three corners are comparable
lr = shapely.geometry.LinearRing([[0, 0],
                                  [50, (100**2-50**2)**0.5],
                                  [100, 0]])
print(lr.is_closed)  # is closed as expected
print(list(lr.coords))  # the three given coordinates plus the closing [0, 0]
lr_buffered = lr.buffer(2, 2)
print(list(lr_buffered.exterior.coords))  # UNEXPECTED: more vertices than expected around [0, 0]

The output for the last print is a mess, but let me describe it here:

  1. 4 vertices around the first input vertex.
  2. 4 vertices around the second input vertex.
  3. 4 vertices around the third input vertex.
  4. Another 8 vertices around the fourth/first input vertex.

Operating system

Linux manjaro 5.3.7-2-MANJARO SMP PREEMPT Tue Oct 22 18:56:05 UTC 2019 x86_64 GNU/Linux

Shapely version and provenance

1.6.4.post2 installed from PyPI using pip

Thanks for your work on shapely and for looking into this issue.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
sgilliescommented, Feb 7, 2022

I’m going to close this one. GEOS 3.10.x is making its way into distributions of shapely.

1reaction
jorisvandenbosschecommented, Jan 3, 2022

With latest Shapely and GEOS (3.10.1), I get the expected result (4 vertices in each corner):

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected behavior of buffer with LinearRing object #790
Maybe I'm using the LinearRing in an unsupported fashion, but when I use LinearRing.buffer I get more vertices than expected around the first...
Read more >
Unexpected behavior of collect() in geometry generator
I'm having unexpected results using geometry generator with the following expression: buffer(collect($geometry),0).
Read more >
Shapely Documentation - Read the Docs
Shapely is a BSD-licensed Python package for manipulation and analysis of planar geometric objects. It is using.
Read more >
Shapely and geometry objects - Automating GIS Processes
Shapely and geometry objects#. In this lesson, you will learn how to create and manipulate geometries in Python using the Shapely Python Package....
Read more >
Solved: Buffer tool with parameters - Esri Community
Solved: Hi - I've been trying to implement some of the code samples that use the drawing toolbar, along with buffer parameters and...
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