gpt4 book ai didi

python - shapely.geos.ReadingError : Could not create geometry because of errors while reading input

转载 作者:太空宇宙 更新时间:2023-11-03 15:17:24 27 4
gpt4 key购买 nike

当我尝试对以下输入使用 shapely.wkt.loads 时,标题中出现错误:

POLYGON((-93.577695846689437 40.813390731817726,-93.577674865779628 40.813444137603014,-93.577722549304582 40.8136196133706,-93.577945709640048 40.814004897950532,-93.5781135556297 40.814165115070466,-93.578243255589527 40.814229965262996,-93.578363418973865 40.814268111930119,-93.578405380213241 40.814252853305611,-93.578418731892242 40.814207077283442,-93.578376770009427 40.81411170971851,-93.578311920291867 40.814050674367543,-93.578300476322624 40.814008712491074,-93.578235626128318 40.813978195044577,-93.5779953002333 40.813646316512269,-93.577934265283389 40.813581466662242,-93.577924728143131 40.813535690301279,-93.577777862415886 40.813383102422016,-93.577695846689437 40.81339073181772))

它采用 WKT 格式,为您省去了滚动浏览所有内容的麻烦。它是我正在阅读的大约 100 个多边形之一,也是唯一一个抛出此错误的多边形。明确地说,当我打电话时:

p = loads('POLYGON((-93.577695846689437 40.813390731817726,-93.577674865779628 40.813444137603014,-93.577722549304582 40.8136196133706,-93.577945709640048 40.814004897950532,-93.5781135556297 40.814165115070466,-93.578243255589527 40.814229965262996,-93.578363418973865 40.814268111930119,-93.578405380213241 40.814252853305611,-93.578418731892242 40.814207077283442,-93.578376770009427 40.81411170971851,-93.578311920291867 40.814050674367543,-93.578300476322624 40.814008712491074,-93.578235626128318 40.813978195044577,-93.5779953002333 40.813646316512269,-93.577934265283389 40.813581466662242,-93.577924728143131 40.813535690301279,-93.577777862415886 40.813383102422016,-93.577695846689437 40.81339073181772))')

我收到错误:shapely.geos.ReadingError: Could not create geometry because errors while reading input.

我什至不厌其烦地将其解析为常规的 shapely.geometry.Polygon 格式。然后,它工作正常。但我宁愿不要让烦人的字符串解析(以及难看的 try/except)弄乱代码。而且,当然,shapely/wky.py 文件绝对没有告诉我任何信息......如果有人知道发生了什么/如何修复它,我将不胜感激。谢谢!

最佳答案

几何包含非闭合环。查看第一个和最后一个坐标:

  • -93.577695846689437 40.813390731817726
  • -93.577695846689437 40.81339073181772

在最后一个坐标字符串的末尾添加6 将使两者相等,并且外壳为构成多边形所需的闭合线性环。

关于python - shapely.geos.ReadingError : Could not create geometry because of errors while reading input,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19862863/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com