Shapely: buffer() drops 3rd dimension

Created on 17 Feb 2020  ·  3Comments  ·  Source: Toblerity/Shapely

Expected behavior and actual behavior.

Expected:

>> from shapely.geometry import LineString
>> geometry_3d = LineString(((0, 0, 1), (10, 0, 2)))
>> list(geometry_3d.buffer(2, cap_style=2).exterior.coords)
[(10.0, 2.0, 2.0), (10.0, -2.0, 2.0), (0.0, -2.0, 1.0), (0.0, 2.0, 1.0), (10.0, 2.0, 2.0)]

Current behavior:

>> from shapely.geometry import LineString
>> geometry_3d = LineString(((0, 0, 1), (10, 0, 2)))
>> list(geometry_3d.buffer(2, cap_style=2).exterior.coords)
[(10.0, 2.0), (10.0, -2.0), (0.0, -2.0), (0.0, 2.0), (10.0, 2.0)]

Steps to reproduce the problem.

Create polygons with 3D coordinates and use buffer() on it. The Z coordinates are not computed.

Operating system

macOS 10.15.3

Shapely version and provenance

1.7.0 installed from PyPI using pip

upstream bug wontfix

Most helpful comment

Done in 016d736.

All 3 comments

@jrobichaud this is a known issue. I've added a new entry to the FAQ about this: https://github.com/Toblerity/Shapely/blob/master/FAQ.rst#i-used-buffer-on-a-geometry-with-z-coordinates-where-did-the-z-coordinates-go.

I think it would be appropriate to document this on the buffer function documentation?

Done in 016d736.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benediktbrandt picture benediktbrandt  ·  3Comments

LostFan123 picture LostFan123  ·  5Comments

romainfontaine picture romainfontaine  ·  5Comments

LostFan123 picture LostFan123  ·  3Comments

sgillies picture sgillies  ·  6Comments