Skip to main content
Solved

Extract XY from this string

  • Jun 13, 2016 3:04 PM UTC
  • 5 replies
  • 79 views

Forum|alt.badge.img

any idea what the best way to extract the xy location from this string would be?

{"type":"Point","coordinates":[-1.35507,52.83477]}

Best answer by davideagle

regex.fmw should sort you out. Use regex to grab the contents of the square brackets and then split the string in the usual way with the AttributeSplitter.

Hope that helps, Dave

View original
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

davideagle
Contributor
Forum|alt.badge.img+21
  • Contributor
  • Best Answer
  • Jun 13, 2016 3:19 PM UTC

regex.fmw should sort you out. Use regex to grab the contents of the square brackets and then split the string in the usual way with the AttributeSplitter.

Hope that helps, Dave


david_r
Celebrity
  • Jun 13, 2016 3:28 PM UTC

In addition to the regex-based solution by @1spatialdave, you can also use the JSONExtractor (since what you posted looks to be JSON) and do the whole extraction with a single transformer.

To extract your coordinates into the attributes x and y, use:


davideagle
Contributor
Forum|alt.badge.img+21
  • Contributor
  • Jun 13, 2016 3:34 PM UTC

In addition to the regex-based solution by @1spatialdave, you can also use the JSONExtractor (since what you posted looks to be JSON) and do the whole extraction with a single transformer.

To extract your coordinates into the attributes x and y, use:

Nice one @david_r


Forum|alt.badge.img
  • Author
  • Jun 13, 2016 3:43 PM UTC

thank you both for your help still getting my head around the regex expressions. perfect :)


revesz
Supporter
Forum|alt.badge.img+22
  • Supporter
  • Jun 13, 2016 3:44 PM UTC

Well, it is the geometry part of a GeoJSON.

Actually GeometryReplacer might be your best friend. It converts the string to feature if you tell the transformer that it is a GeoJSON :)

So you can use the CoordinateExtractor and no coding involved.