Solved

Create polygon from string of coordinates

  • 8 January 2024
  • 5 replies
  • 35 views

Badge +1

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.

 

 

icon

Best answer by dustin 8 January 2024, 14:19

View original

5 replies

Userlevel 1
Badge +10

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!

Userlevel 3
Badge +25

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

Userlevel 1
Badge +10

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!

Badge +1

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. 

Badge +1

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

Reply