Skip to main content
Solved

Create polygon from string of coordinates


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

View original
Did this help you find an answer to your question?

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+30
  • 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
dustin wrote:

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
dustin wrote:

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings