2

Can someone help me with a regex to extract the 3-D coordinates within the MULTIPOLYGON in this list:

[(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)))')]
2

1 Answer 1

2

I think this regex may find what you're looking for in your string: '([\d.]+?)\s([\d.]+?)\s([\d.]+?)'

I tested it with python and it returns a list of lists of coordinates:

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)

It prints:

[('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')]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.