Question

simple txt to coordinate

  • 25 January 2018
  • 3 replies
  • 12 views

Badge

Hi,

I have a simple txt with many coordinates like (no header):

554174.746999408, 5598075.08612377, 554175.302999408, 558090.53212377, 554177.963999408, 5598129.63312377, 554182.011999408, 5598160.71912377, 554182.176999408, 5598181.49312377, 554180.422999408, 5598212.50312377, 554172.863999408, 5598249.02912377, 554167.975999407,

I want to validate that geometry. I tried using different readers (txt, csv) and transformers like stringreplacer.

I found this question

https://knowledge.safe.com/questions/39344/use-of-the-geometryreplacer.html

but could not modify my workbench with success.

Any hints on that?


3 replies

Badge

Hi @nhaz,

assuming that your data is a comma separated list of x and y coordinates (order x, y, x, y ,etc.). I also assume that you would like to have a Point Feature at the end:

Hope this helps

Badge +3

easyconnect.fmw

Use stringsearcher on the text with regexp ([\\d.]+),\\s*([\\d.]+), advanced set AllMatch.

Listexplode AllMatch. You have coordinate list now.

Split by "," using a splitter.

Create vertex list{0},list{1}

Sort by _lelement_index. (generated by the exploder)

Pointconnector.

Userlevel 2
Badge +17

Hi @nhaz, if the string is comma-separated coordinates list (x, y, x, y, ...), you can convert it to space-separated coordinates list and then apply the GeometryReplacer.

Try setting these parameters to the GrometryReplacer. Assuming that the attribute "_coordinates" stores the comma-separated coordinates list.

  • Geometry Encoding: GML
  • GML SRS Axis Order: 1,2
  • Geometry Source:
<gml:LineString>
<gml:posList>@ReplaceString(@Value(_coordinates),","," ")</gml:posList>
</gml:LineString>

Reply