Skip to main content
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?
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'>
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
Thats right, thank you for this shortcut.

Reply