Buffer crashes: ValueError: No Shapely geometry can be created from null value
See original GitHub issueExpected 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:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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?
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.