"POLYGON M" WKB fails to import
See original GitHub issueExpected behavior and actual behavior.
Expected: Both the WKT and WKB representations of the same geometry, given below, import successfully via shapely.wkt.loads
and shapely.wkb.loads
Actual: The WKT load succeeds, but the WKB load fails with:
2020-03-12 09:10:03,948 geos@248:callback 39818 [ERROR] IllegalArgumentException: Points of LinearRing do not form a closed linestring
Unable to load WKB for 0: Could not create geometry because of errors while reading input.
The WKT and WKB have been exported from the same GDAL/OGR geometry object. GDAL’s geom.IsValid()
returns True. I think the key here is that the original geometry object is a Polygon M (WKB code 2003), although all M-dimension data is zero. The WKT is a POLYGON, but if I run the WKB through a WKB-to-WKT converter (https://tools-utils.com/wkb-to-wkt), the output shows POLYGON M.
I’ve no expectation for Shapely to do anything but ignore the M coordinate - in honesty, I thought the geometries I’m putting were plain 2D Polygons until encountering this error. I can’t find any reference in the Shapely documentation to say that xyz/xym/xyzm WKT/WKB data are not supported, but if they aren’t, could a note be added?
Polygon Data
WKT
POLYGON ((12.8990928280001 48.2366553950001,12.901280264 48.237871727,12.9057534630001 48.2383257660001,12.917987677 48.238403244,12.9279219110001 48.2356819,12.938501708 48.226425035,12.938849012 48.2191551340001,12.9367461190001 48.2126389950001,12.9335506580001 48.2116509730001,12.933031307 48.2115114900001,12.9326327100001 48.211934785,12.932395265 48.2124009620001,12.932199584 48.2123707870001,12.932422838 48.211963946,12.932153339 48.2118767760001,12.9319352840001 48.2117646560001,12.93185328 48.2115663800001,12.9329065900001 48.2111846450001,12.9326532160001 48.211177762,12.9307220260001 48.211978507,12.927417545 48.2136085540001,12.923598079 48.2154959120001,12.9196927830001 48.217955094,12.9160020620001 48.220528529,12.912397174 48.223359159,12.909993914 48.22544629,12.907933977 48.2273332120001,12.904414919 48.2308781510001,12.9028270530001 48.2328792170001,12.9020974910001 48.2335652790001,12.9013250140001 48.234279918,12.8996083100001 48.2353912790001,12.8990928280001 48.2366553950001))
WKB
00000007d300000001000000214029cc55e528a82040481e4ab956f94000000000000000004029cd749b54d22040481e7294ac0dd800000000000000004029cfbeeafba5e040481e81756d61d800000000000000004029d6027b15b14040481e83ff5c1ec800000000000000004029db1894a9f96040481e2ad312613000000000000000004029e0834bbe336040481cfb7edc291000000000000000004029e0b0d154d82040481c0d4682a3f000000000000000004029df9d2ff3854040481b37c12cb09800000000000000004029ddfa5a128a0040481b17610b99d800000000000000004029ddb6478b6b2040481b12cefa23a800000000000000004029dd8208d942a040481b20add53ae000000000000000004029dd62e9843da040481b2ff468b6f000000000000000004029dd49438d400040481b2ef748654000000000000000004029dd6686b681e040481b21a274002800000000000000004029dd4333d3b98040481b1ec737d9e000000000000000004029dd269f1d89a040481b1b1aaffc0800000000000000004029dd1bdf848a8040481b149b6d844800000000000000004029dda5eebc8be040481b081933d8a800000000000000004029dd84b8ea758040481b07df76b76000000000000000004029dc8798eeaca040481b221c99829000000000000000004029dad678f3060040481b57866cc9c000000000000000004029d8e1d8efe84040481b955ebb3b2000000000000000004029d6e1f8f2b48040481be5f3d85d0800000000000000004029d4fe38e6b7c040481c3a4761f1f000000000000000004029d325b8ee960040481c97086d956800000000000000004029d1eab8e860e040481cdb6c8d470000000000000000004029d0dcb8e448e040481d1941336ae000000000000000004029cf0f78e63d4040481d8d6a4df40000000000000000004029ce3f58f528a040481dcefc76777800000000000000004029cddfb8eb4c4040481de5779164a800000000000000004029cd7a78e464e040481dfce264f5b800000000000000004029cc9975dd520040481e214d2a88d000000000000000004029cc55e528a82040481e4ab956f9400000000000000000
Steps to reproduce the problem.
import shapely.wkb
import shapely.wkt
wkt = "POLYGON ((12.8990928280001 48.2366553950001,12.901280264 48.237871727,12.9057534630001 48.2383257660001,12.917987677 48.238403244,12.9279219110001 48.2356819,12.938501708 48.226425035,12.938849012 48.2191551340001,12.9367461190001 48.2126389950001,12.9335506580001 48.2116509730001,12.933031307 48.2115114900001,12.9326327100001 48.211934785,12.932395265 48.2124009620001,12.932199584 48.2123707870001,12.932422838 48.211963946,12.932153339 48.2118767760001,12.9319352840001 48.2117646560001,12.93185328 48.2115663800001,12.9329065900001 48.2111846450001,12.9326532160001 48.211177762,12.9307220260001 48.211978507,12.927417545 48.2136085540001,12.923598079 48.2154959120001,12.9196927830001 48.217955094,12.9160020620001 48.220528529,12.912397174 48.223359159,12.909993914 48.22544629,12.907933977 48.2273332120001,12.904414919 48.2308781510001,12.9028270530001 48.2328792170001,12.9020974910001 48.2335652790001,12.9013250140001 48.234279918,12.8996083100001 48.2353912790001,12.8990928280001 48.2366553950001))"
wkb = bytes.fromhex("00000007d300000001000000214029cc55e528a82040481e4ab956f94000000000000000004029cd749b54d22040481e7294ac0dd800000000000000004029cfbeeafba5e040481e81756d61d800000000000000004029d6027b15b14040481e83ff5c1ec800000000000000004029db1894a9f96040481e2ad312613000000000000000004029e0834bbe336040481cfb7edc291000000000000000004029e0b0d154d82040481c0d4682a3f000000000000000004029df9d2ff3854040481b37c12cb09800000000000000004029ddfa5a128a0040481b17610b99d800000000000000004029ddb6478b6b2040481b12cefa23a800000000000000004029dd8208d942a040481b20add53ae000000000000000004029dd62e9843da040481b2ff468b6f000000000000000004029dd49438d400040481b2ef748654000000000000000004029dd6686b681e040481b21a274002800000000000000004029dd4333d3b98040481b1ec737d9e000000000000000004029dd269f1d89a040481b1b1aaffc0800000000000000004029dd1bdf848a8040481b149b6d844800000000000000004029dda5eebc8be040481b081933d8a800000000000000004029dd84b8ea758040481b07df76b76000000000000000004029dc8798eeaca040481b221c99829000000000000000004029dad678f3060040481b57866cc9c000000000000000004029d8e1d8efe84040481b955ebb3b2000000000000000004029d6e1f8f2b48040481be5f3d85d0800000000000000004029d4fe38e6b7c040481c3a4761f1f000000000000000004029d325b8ee960040481c97086d956800000000000000004029d1eab8e860e040481cdb6c8d470000000000000000004029d0dcb8e448e040481d1941336ae000000000000000004029cf0f78e63d4040481d8d6a4df40000000000000000004029ce3f58f528a040481dcefc76777800000000000000004029cddfb8eb4c4040481de5779164a800000000000000004029cd7a78e464e040481dfce264f5b800000000000000004029cc9975dd520040481e214d2a88d000000000000000004029cc55e528a82040481e4ab956f9400000000000000000")
# Works
shapely.wkt.loads(wkt)
# Get error
shapely.wkb.loads(wkb)
Operating system
Scientific Linux 7.6
Shapely version and provenance
1.7.0 via pip
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
Thanks @davidraleigh this is an upstream issue with GEOS, see trac#676
Wow, open for 7 years in GEOS.