我想将 XY 坐标的 WKB 表示形式转换为 YX 格式。我正在使用的代码适用于 42 个字符的 WKB 字符串,但是当我在 50 个字符的字符串上使用它时,它会给我一个奇怪的 YX 输出。我正在运行 Python 2.7.5。
这是我的代码:
from osgeo import ogr
from binascii import unhexlify
## converts a WKB string into a YX coordinate
input = raw_input("Enter WKB string: ")
wkb = unhexlify(input)
point = ogr.CreateGeometryFromWkb(wkb)
print "%.3f,%.3f" % (point.GetY(), point.GetX())
# no work 0101000020E6100000BD30B7B921A85AC07513F26D8A1A4840
# work 0101000000C458A65F22A85AC0E412471E881A4840
当我输入 42 个字符串时,我的结果很好: POINT (-106.627098 48.207279)
但是当我输入我的 50 个字符串时,我得到: 35551347284760172989733196762993524505383784689069116267735275384883630368447731158999360461880613447190932995080.60.61
当我只打印点时,我得到这个: POINT (-0.0 too_big)
谁能帮我解释一下?