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.

Buffer crashes: ValueError: No Shapely geometry can be created from null value

See original GitHub issue

Expected behavior and actual behavior.

I encountered “ValueError: No Shapely geometry can be created from null value” when I tried to get the buffer area of a sequence of locations (represented as pair of [grid_x, grid_y]).

Steps to reproduce the problem.

(For example, a script with required data) Here is the link of test input. test.csv And error happens after running the following script. df = pd.read_csv("test.csv") grid_path = df.loc[:, ['grid_x','grid_y']].values.tolist() path = LineString(grid_path) print("path is valid?", path.is_valid) buffer_path = path.buffer(2, cap_style=1)

Operating system

Mac OS X 10.13.6

Shapely version and provenance

I used 1.6.4. post 2 from PyPI using pip

Thank you for any help!

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
sgilliescommented, Dec 6, 2018

I’m happy to see that there is not an actual crashing bug here: you can recover from an exception, but not from a true crash.

@jGaboardi thanks for your help! Nodes that are very close to each other, closer than our computers’ precision, are a problem for some of the algorithms in GEOS. Simplifying geometries has helped in some cases.

@RuiR I’m happy to look into this and even to take it upstream to GEOS if needed, but I need a less complicated example to see if I can reproduce the problem. Can you paste here a representation (WKT, for example) of a geometry that can’t be buffered?

0reactions
RuiRcommented, Jan 14, 2019

As @jGaboardi suggested, I buffered each segment path and dissolve all buffer using cascaded_union imported from shapely.ops. This works fine and runs quickly.

But the result is not the same with the previous method (buffering the long LineString of the whole path). I’m curious about the process of buffering the whole path.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Buffer crashes: ValueError: No Shapely geometry can ... - GitHub
I encountered "ValueError: No Shapely geometry can be created from null value" when I tried to get the buffer area of a sequence...
Read more >
Dissolve causes 'No Shapely geometry can be created from ...
the Error says that your polygons do have a self intersection at the given coordinates, to avoid it you will have to reconstruct...
Read more >
ValueError: No Shapely geometry can be created from null value
I have validated that my polygons are valid. Initially polyB isn't valid, but it is converted to a valid polygon using buffer(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 the widely deployed open-source ...
Read more >
GIS: No Shapely geometry can be created from null value ...
GIS: No Shapely geometry can be created from null value during dissolve in Geopandas?Helpful? Please support me on Patreon: ...
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