Solved

geometrycoercer - OGC WKT type

  • 14 August 2014
  • 3 replies
  • 4 views

Badge
I discovered that the OGC WKT geometry obtained by the geometryCoercer is not a string object but a bytearray object

 

 

In a python caller:

 

 

wkt = feature.getAttribute('_geometry')

 

print type(wkt)

 

>>> <type 'bytearray'>

 

 

I think that's weird because WKT stands for Well Known Text and should be just string object. In my experience FME is the only tool where WKT geometry is not a string.  Why FME store WKT in a bytearray object?
icon

Best answer by burton449 14 August 2014, 15:40

View original

3 replies

Badge
Alright the answer to convert WKT bytearray to string is the following:

 

 

in a python caller:

 

 

wkt = str(feature.getAttribute('_geometry').decode("ascii", "ignore"))

 

print type(wkt)

 

>>> <type 'str'>
Userlevel 4
Hi,

 

 

here is another and easier way to do get the same thing:

 

 

wkt = feature.exportGeometryToOGCWKT()

 

 

This way you can also skip the GeometryExtractor before the PythonCaller.

 

 

David
Badge
Thats right, thank you for this shortcut.

Reply