Skip to main content
Solved

GeometryReplacer rejects valid WKT

  • November 21, 2025
  • 10 replies
  • 145 views

s.jager
Influencer
Forum|alt.badge.img+23

Using FME Form 2025.1.1.0, I have some 30.000 features that have an attribute containing a polygon in Well-Known Text form. For about 4000 of those, GeometryReplacer rejects them with the fme_rejection_code of ‘INVALID_PARAMETER_GEOMETRY_SOURCE.

If I check the WKT, I can’t find any problems with it, and if I use https://wktmap.com/ (with an EPSG:28992) the handful of polygons I’ve checked show up just fine without any errors.

Example of one that goes wrong but looks good to me (and wktmap):
POLYGON ((78388.897 419890.033, 78421.563 419868.628, 78426.311 419875.727, 78429.69 419880.662, 78426.428 419884.195, 78422.297 419888.73, 78417.812 419891.98, 78413.315 419895.15, 78401.216 419903.072, 78397.477 419905.515, 78379.315 419917.4, 78377.366 419915.657, 78378.144 419913.401, 78379.163 419910.789, 78381.446 419908.255, 78384.409 419905.029, 78389.638 419899.094, 78392.82 419895.507, 78388.897 419890.033))

As far as I can work out, it does seem to always be the same features (this is from the pre-processing part of the workspace), so it either must be something with the WKT or with GeometryReplacer imho, but I can’t figure out what it is.

 

Edit: changing the OGC WKT Precision setting from 64-bit to 32-bit does not make any difference, btw.

Edit 2: these features come from an SQLCreator connecting to an MS SQL Server. The WKT attribute is created using ::geometry.STASText(). If I add STAsBinary(), then use the binary in the geometryreplacer, there’s no problem. In the logs of FME Form I see an entry “Invalid WKT encountered: P”. It almost seems like the buffer (which is the FME data type the WKT-attribute receives) is not fully read. What I don’t understand though is that it always seem to be the same features, it’s definitely always the same amount of features. I don’t want to use Binary however, since we sometimes get EMPTY POLYGON geometries in our database - and that is easy to check if it is WKT… But for now I’ll use it as a workaround.

 

Best answer by daveatsafe

The log shows the encoding of the WKT as UTF-16LE. Recent versions of FME have had some issues with attributes in that encoding, especially on Macs. These issues are being fixed for FME 2025.2, but for now, please try using an AttributeEncoder transformer to force the WKT to UTF-8 before the GeometryReplacer:

 

10 replies

ebygomm
Influencer
Forum|alt.badge.img+46
  • Influencer
  • November 21, 2025

The WKT you posted works without issue in a GeometryReplacer for me in 2025.1. 

If it’s coming from STASText() i wouldn’t expect there to be any rogue characters that have been lost when you’ve posted here. 

 


s.jager
Influencer
Forum|alt.badge.img+23
  • Author
  • Influencer
  • November 21, 2025

The WKT you posted works without issue in a GeometryReplacer for me in 2025.1. 

That’s why I don’t understand this one. I don’t see any strange characters, the WKB works fine, and the polygons aren’t even strange or invalid ones.

For now I select both WKT (to check for EMPTY polygons) and WKB (to catch this strange problem: use the 1st GeometryReplacer’s Rejected port, send that into a second GeometryReplacer that uses the WKB), and that seems to work. But it remains a mysterious one..


s.jager
Influencer
Forum|alt.badge.img+23
  • Author
  • Influencer
  • November 21, 2025

Just noticed that it does not happen in FME 2022.2.6.0. So whatever it is, it was introduced sometime after that.

 


daveatsafe
Safer
Forum|alt.badge.img+20
  • Safer
  • November 24, 2025

I have seen attribute truncations in other cases that were due to the encoding of the attribute. Please try sending the rejected output of the GeometryReplacer to a Logger, then pasting a sample of the logged features.


s.jager
Influencer
Forum|alt.badge.img+23
  • Author
  • Influencer
  • November 25, 2025

Personally I would think that rather strange, seeing as all features come from the exact same SQLCreator using ‘select <snip> geom.STAsText() as WKT from <schema.tablename>’. So if what you say is the cause, then that would mean that either SQL Server or SQLCreator arbitrarily assigned encodings.

But, for the record, I logged 10 Rejected and 10 accepted features, below are 1 of each:

Logger_6: WKT is Rejected

2025-11-25 09:05:39|   8.8|  0.0|INFORM|Attribute(string: UTF-16LE)  : `WKT' has value `POLYGON ((142263.43 415230.511, 142243.062 415232.832, 142183.362 415238.22, 142162.184 415184.308, 142163.012 415156.642, 142165.404 415076.768, 142222.659 415078.312, 142266.986 415079.564, 142284.727 415080.223, 142273.421 415160.009, 142263.43 415230.511))'

 

Logger_7: WKT is OK

2025-11-25 09:05:40|   8.9|  0.0|INFORM|Attribute(string: UTF-16LE)  : `WKT' has value `POLYGON ((142284.727 415080.223, 142318.94 415081.494, 142318.685 415087.235, 142290.319 415160.525, 142283.594 415178.12, 142278.46 415193.675, 142268.535 415229.929, 142263.43 415230.511, 142273.421 415160.009, 142284.727 415080.223))'

 

Note that it is the FME Form log window that adds the ` in front of any text, instead of a regular ‘ as it does at the end (Still find that a strange one, btw). This is a straight copy and paste from FME, some spaces removed for legibility.

Both polygons, when checked on https://wktmap.com, using EPSG:28992, are valid and show up properly on the map, so should be accepted imho.


daveatsafe
Safer
Forum|alt.badge.img+20
  • Safer
  • Best Answer
  • November 25, 2025

The log shows the encoding of the WKT as UTF-16LE. Recent versions of FME have had some issues with attributes in that encoding, especially on Macs. These issues are being fixed for FME 2025.2, but for now, please try using an AttributeEncoder transformer to force the WKT to UTF-8 before the GeometryReplacer:

 


s.jager
Influencer
Forum|alt.badge.img+23
  • Author
  • Influencer
  • November 26, 2025

The log shows the encoding of the WKT as UTF-16LE. Recent versions of FME have had some issues with attributes in that encoding, especially on Macs. 

That does solve it, except for one single feature which remains rejected (WKT attribute for that one contains only a P). So for now I am staying with my own workaround, selecting both WKT and WKB, and using the WKB when any feature is coming out the Rejected-port of the GeometryReplacer. Because that allows me to have every feature coming through.

BTW: We only use Windows 11, no Macs in sight.


daveatsafe
Safer
Forum|alt.badge.img+20
  • Safer
  • November 26, 2025

It looks like we have just released FME 2025.2 (safe.com/download). If you are able to update your FME, it would be helpful to know if you still get the same issue in the new version.


s.jager
Influencer
Forum|alt.badge.img+23
  • Author
  • Influencer
  • November 28, 2025

I can’t update unfortunately, so not able to check that version.

I tried changing the encoding from the database side, but it appears that SQL Server only introduced support for UTF-8 in 2019 (ridiculously late, if you ask me), and our version is an earlier one (which we have to use due to mission critical legacy software unfortunately). So that didn’t work either. Selecting both WKT and WKB, then using the WKB when the first GeometryReplacer rejects the WKT, works fine though. And an AttributeRemover right after the second GeometryReplacer prevents too much memory to be consumed, so for now we’re good.


grahamwood_hwc
Contributor
Forum|alt.badge.img+3

I Had the same issue.. I found the error by extracting geometry the WKT of something related to get the format..

My gotcha was I was encoding as
Polygon ( x1 y2,x2 y2….)
should have been with double brackets
Polygon (( x1 y2,x2 y2….))