Skip to main content
Solved

Create polygon from string of coordinates

  • January 8, 2024
  • 5 replies
  • 585 views

geovision
Contributor
Forum|alt.badge.img+5

I have XML file with features I'm trying to read.. that works. Next step is to create a polygon for each feature, I have a string with points that make the polygon. String looks like this:

 

173363.252 587903.412 173363.369 587902.665 173362.055 587900.798 173363.867 587888.745 173364.007 587887.815 173371.744 587888.843 173368.618 587904.7 173363.252 587903.412

 

That's a list of x and y coordinates, now I can't figure out a idea to make polygons from it. Any ideas? Do I have to seperate them, create lines and make a polygon from it? Any help is appreciated.

 

 

Best answer by dustin

This is what I would do:

  •  With a StringSearcher, use the regex below to extract the coordinate pairs into a list using the All Matches List Name.
([\d.]+) \s*([\d.]+)
  • Using a ListConcatenator, concatenate the list in a single attribute with a comma as the Separator Character between each coordinate pair.
  • Use a GeometryReplacer with OGCWKT encoding with the following Geometry Source to build the geometry.
POLYGON((@Value(_concatenated)))

imageimage

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

joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • January 8, 2024

Hello, the workflow outline you sketched is indeed the way to do this. I did the following:

imageimageimageThere is probably an easier way to do this, but this works pretty good.

imageHope this helps

 

P.S: RD New spotted 😎 veel plezier!


dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • Best Answer
  • January 8, 2024

This is what I would do:

  •  With a StringSearcher, use the regex below to extract the coordinate pairs into a list using the All Matches List Name.
([\d.]+) \s*([\d.]+)
  • Using a ListConcatenator, concatenate the list in a single attribute with a comma as the Separator Character between each coordinate pair.
  • Use a GeometryReplacer with OGCWKT encoding with the following Geometry Source to build the geometry.
POLYGON((@Value(_concatenated)))

imageimage


joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • January 8, 2024

This is what I would do:

  •  With a StringSearcher, use the regex below to extract the coordinate pairs into a list using the All Matches List Name.
([\d.]+) \s*([\d.]+)
  • Using a ListConcatenator, concatenate the list in a single attribute with a comma as the Separator Character between each coordinate pair.
  • Use a GeometryReplacer with OGCWKT encoding with the following Geometry Source to build the geometry.
POLYGON((@Value(_concatenated)))

imageimage

:o Very cool!


geovision
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • January 9, 2024

This is what I would do:

  •  With a StringSearcher, use the regex below to extract the coordinate pairs into a list using the All Matches List Name.
([\d.]+) \s*([\d.]+)
  • Using a ListConcatenator, concatenate the list in a single attribute with a comma as the Separator Character between each coordinate pair.
  • Use a GeometryReplacer with OGCWKT encoding with the following Geometry Source to build the geometry.
POLYGON((@Value(_concatenated)))

imageimage

Thanks! Worked like a charm. 


eldonmarks
Contributor
Forum|alt.badge.img+1
  • Contributor
  • February 9, 2024

Thank you so much for the solution, those suggestions solved my problem also.