Skip to main content
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

redgeographics
Celebrity
Forum|alt.badge.img+53

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?


hkingsbury
Celebrity
Forum|alt.badge.img+59
  • Celebrity
  • May 22, 2022
redgeographics wrote:

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


ebygomm
Influencer
Forum|alt.badge.img+40
  • Influencer
  • May 23, 2022

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

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

 


  • Author
  • May 23, 2022

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.


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