当我尝试对以下输入使用 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 of errors while reading input.
我什至遇到了将其解析为常规 shapely.geometry.Polygon 格式的麻烦。然后,它工作正常。但我宁愿不要用烦人的字符串解析(以及丑陋的尝试/除外)来混乱代码。而且,当然,shapely/wky.py 文件绝对没有告诉我任何信息……如果有人知道发生了什么/如何解决它,我将不胜感激。谢谢!