首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用qgis和shaply错误: GEOSGeom_createLinearRing_r返回一个空指针

使用qgis和shaply错误: GEOSGeom_createLinearRing_r返回一个空指针
EN

Stack Overflow用户
提问于 2020-05-29 06:53:12
回答 3查看 3.3K关注 0票数 7

我尝试在QGIS中创建一个多边形shapefile,并用python逐个读取它。示例代码如下所示:

代码语言:javascript
运行
复制
import fiona
from shapely.geometry import shape
multipolys = fiona.open(somepath)
multi = multipolys[0]
coord = shape(multi['geometry'])

EOSGeom_createLinearRing_r返回一个空指针,检查多边形在QGIS中是否有效,并且没有报告错误。实际上,它甚至不适用于在QGIS中生成的一个简单的三角形。有人知道怎么解决这个问题吗?

谢谢

EN

Stack Overflow用户

发布于 2020-09-02 00:35:28

和J. P.一样,我在创建LineStrings时也遇到了这个问题。在Shapely github存储库中有an old issue (2016),这似乎是相关的。更改导入的顺序为我解决了问题:

代码语言:javascript
运行
复制
from shapely.geometry import LineString
import fiona 

LineString([[0, 0], [1, 1]]).to_wkt()
# 'LINESTRING (0.0000000000000000 0.0000000000000000, 1.0000000000000000 1.0000000000000000)'

鉴于

代码语言:javascript
运行
复制
import fiona
from shapely.geometry import LineString

LineString([[0, 0], [1, 1]]).to_wkt()
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
#   File "C:\Users\xxxxxxx\AppData\Roaming\Python\Python37\site-packages\shapely\geometry\linestring.py", line 48, in __init__
#     self._set_coords(coordinates)
#   File "C:\Users\xxxxxxx\AppData\Roaming\Python\Python37\site-packages\shapely\geometry\linestring.py", line 97, in _set_coords
#     ret = geos_linestring_from_py(coordinates)
#   File "shapely\speedups\_speedups.pyx", line 208, in shapely.speedups._speedups.geos_linestring_from_py
# ValueError: GEOSGeom_createLineString_r returned a NULL pointer

Shapely存储库中需要查看的其他一些问题

针对Mac

  • 887上的导入顺序问题的
  • 553 (与shapely)
  • 919

osgeo的反向导入顺序技巧相同

票数 9
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62075847

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档