1

有人可以帮助我使用正则表达式来提取此列表中 MULTIPOLYGON 中的 3-D 坐标:

[(1,
  'public Library',
  'SRID=4326;MULTIPOLYGON(((352877.02163887 1233618.83923531 5,352872.32998848 1233609.44478035 5,352867.693426132 1233612.15611458 5,352861.67354393 1233602.76770592 5,352841.814386368 1233616.9818058 5,352848.495328903 1233625.69463921 5,352861.076768875 1233617.56668663 5,352866.429475784 1233626.28557014 5,352877.02163887 1233618.83923531 5)))')]
4

1 回答 1

2

我认为此正则表达式可能会在您的字符串中找到您要查找的内容: '([\d.]+?)\s([\d.]+?)\s([\d.]+?)'

我用python对其进行了测试,它返回了一个坐标列表列表:

import re
foo = "SRID=4326;MULTIPOLYGON(((352877.02163887 1233618.83923531 5,352872.32998848 1233609.44478035 5,352867.693426132 1233612.15611458 5,352861.67354393 1233602.76770592 5,352841.814386368 1233616.9818058 5,352848.495328903 1233625.69463921 5,352861.076768875 1233617.56668663 5,352866.429475784 1233626.28557014 5,352877.02163887 1233618.83923531 5)))"
print re.findall('([\d.]+?)\s([\d.]+?)\s([\d.]+?)', foo)

它打印:

[('352877.02163887', '1233618.83923531', '5'), ('352872.32998848', '1233609.44478035', '5'), ('352867.693426132', '1233612.15611458', '5'), ('352861.67354393', '1233602.76770592', '5'), ('352841.814386368', '1233616.9818058', '5'), ('352848.495328903', '1233625.69463921', '5'), ('352861.076768875', '1233617.56668663', '5'), ('352866.429475784', '1233626.28557014', '5'), ('352877.02163887', '123361 8.83923531', '5')]
于 2012-08-08T14:19:27.037 回答