Question

Hi, I have a TSV (Tab Seperated Value) file with a geomertry column that contains WKT stings. In many cases there are multiple WKT strings in the same geometry column, that are sepeated by a comma(,). How do I best generate each geometry?


Attribute Splitter and List Exploder? or is there a better way?


4 replies

Userlevel 5
Badge +25

So this is probably going to be a bit of a challenge: a WKT string can contain comma's too... So the AttributeSplitter by itself is not going to work

 

You can try a StringReplacer with a regular expression to look for the regex \\), \\w, which would supposedly find the comma's separating the various geometries, but I think they'd find comma's separating the parts of multi-geometries too.

 

I'm a bit rusty on regular expressions, just out of curiousity, what kinds of geometry can be in there?

Userlevel 5
Badge +29

So this is probably going to be a bit of a challenge: a WKT string can contain comma's too... So the AttributeSplitter by itself is not going to work

 

You can try a StringReplacer with a regular expression to look for the regex \\), \\w, which would supposedly find the comma's separating the various geometries, but I think they'd find comma's separating the parts of multi-geometries too.

 

I'm a bit rusty on regular expressions, just out of curiousity, what kinds of geometry can be in there?

Agree with @Hans van der Maarel​ ,​  @phild​ if you could provide an example that would be great

Userlevel 1
Badge +21

Assuming the commas to split on are only those that are outside brackets you could use regex to replace the commas with e.g. a colon, and then use an attributesplitter on this followed by a list exploder. Then a geometry replacer to build the geometries

,(?![^()]*\))

 

Thanks to all. @Hans van der Maarel​ the geometries are building polygons and turns out they are sperated by ),( as each WKT string starts and stops so I was able to use a string searcher and replace that with )#( to give me a unique delimiter. @hkingsbury​ sorry, but customer data so can not share. @ebygomm​ thanks for the tip.

Reply