Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: GEOSGeom_createLinearRing_r returned a NULL pointer #919

Closed
wmobley opened this issue May 25, 2020 · 3 comments
Closed

ValueError: GEOSGeom_createLinearRing_r returned a NULL pointer #919

wmobley opened this issue May 25, 2020 · 3 comments

Comments

@wmobley
Copy link

wmobley commented May 25, 2020

When loading a polygon shapefile using Fiona and then converting that to a Shapely Polygon Shape returns the following error.
ValueError: GEOSGeom_createLinearRing_r returned a NULL pointer

`shp = fiona.open(r"shapefile.shp", 'r')
for pol in shp:

print(Polygon(pol['geometry']['coordinates'][0]))`

I went back to version Version: 1.6.4.post2 and it fixed the error.

Operating system

Windows 10
Shapely version 1.7.0 from pip
Reverted to 1.6.4.post2 fixed the error.

@sgillies
Copy link
Contributor

@wmobley thank you for the report. We need more information before we can begin to diagnose the situation. Can you copy here the value of pol['geometry'] which triggers the exception?

@wmobley
Copy link
Author

wmobley commented May 25, 2020

Ok, heres a csv with the polygon points. This was converted already in 1.6.4.post2, but you should be able to get what you need out of it. If not I can send the original shape file if that would work.
test.zip

@sgillies
Copy link
Contributor

@wmobley I'm able to read and parse all the geometries with the following script.

import csv

from shapely.wkt import loads

with open("/Users/seang/Downloads/test.csv") as fobj:
    reader = csv.reader(fobj)
    header = next(reader)
    for row in reader:
        try:
            g = loads(row[1])
            print(g.wkt)
        except:
            import pdb; pdb.set_trace()
            pass

If there's a problem, it's not in Shapely. I think that you may be experiencing some DLL incompatibility between Fiona and Shapely. We didn't have 1.6.4.post2 binary wheels for Windows on PyPI and don't have Fiona binary wheels for Windows on PyPI. You'll need to get Fiona and Shapely from the same package provider and then I think could can expect better results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants