Question

Switch polygon coordinates with new ones

  • 3 February 2020
  • 6 replies
  • 17 views

Badge +6

Hi FMEUsers!

I wanted to know if there is any transformer or workaround to switch/modify directly one or various pair of X,Y coordinates from a polygon with new ones, so, the polygon should be reshaped based on that change.

Here is an example:

 

 

From the selected polygon, the current vertex from the Polygon (green arrow) would need to be changed, with the X,Y from the Point (red arrow).

 

I'm wondering what should be the smartest and less consuming way to build that?... Imagine launching for thousands of Polygons...

Thanks!!

Btw, I'm using FME2019


6 replies

Badge +15

Hi Juanma,

 

I think the AnchoredSnapper with Snapping Type: Vertex Snapping should be what you're looking for:

Your points should be the anchors and the polygons the candidates.

Cheers,

 

Francisco
Badge +6

Hi Juanma,

 

I think the AnchoredSnapper with Snapping Type: Vertex Snapping should be what you're looking for:

Your points should be the anchors and the polygons the candidates.

Cheers,

 

Francisco

I knew that Transformer, and results are quite unstable (images below) since I really need to point which vertex are needed to be moved and which no. For that reason, I wanted to rebuild the entire polygon, giving then the new information where the chosen vertex has a new X,Y coordinate. Even though, I'll give a try again to the AnchoredSnapper, maybe a workaround using it could help to solve this topic.

ex1

 

 

ex2:

I'll keep trying.

Thanks @fgiron!

J.

Userlevel 2
Badge +12

If you know exactly what coordinates to replace with what new coordinates, this will work:

Use GeometryExtractor to extract WKT type geometry to a text attribute.

Then use StringReplacer to replace old coordinates with new coordinates.

And finally GeometryReplacer to replace geometry with WKT geometry from text attribute.

But this only works if you know the exact old coordinates and new coordinates.

Badge +6

If you know exactly what coordinates to replace with what new coordinates, this will work:

Use GeometryExtractor to extract WKT type geometry to a text attribute.

Then use StringReplacer to replace old coordinates with new coordinates.

And finally GeometryReplacer to replace geometry with WKT geometry from text attribute.

But this only works if you know the exact old coordinates and new coordinates.

Thanks @erik_jan , wise solution too. But I'm finding now a second block. Since could be easy to change/swap vertex values on one case (detected VERTEX-A to swap values with VERTEX-Z,... what if a polygon need to swap a couple of vertexes: VERTEX-A and VERTEX-B must be changed with VERTEX-Z and VERTEX-Y, on that precise order?

Here is an example, where I encountered that situation:

 

From that case, Polygon "C", those 2 vertexes (yellow and purple arrow) need to be relocated to the green and pink arrow vertex, but also on that precise order.

 

 

I'm trying to find the logic from where when it sets the first iteration (swapping yellow TO green) continues on with next iteration (swapping purple TO pink), using the new "_geometry" value after used StringReplacer.

My doubt here, how could I sequentially perform that change taking into account last "_geometry" value changed?

 

Thanks!

Badge +2

@juanmahere VertexCreator has an option Replace Point at Index. Combined with CoordinateExtractor and ListSearcher that might give you what you need.

To loop through all the points, you can wrap the algorithm in a Custom Transformer

Badge +6

@juanmahere VertexCreator has an option Replace Point at Index. Combined with CoordinateExtractor and ListSearcher that might give you what you need.

To loop through all the points, you can wrap the algorithm in a Custom Transformer

Hi @markatsafe, let me check that option and I'll post again if it's the desired output. Thanks for your help!! ;)

Reply