Skip to main content
Solved

geometrycoercer - OGC WKT type

  • August 14, 2014
  • 3 replies
  • 42 views

Forum|alt.badge.img
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?

Best answer by burton449

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'>
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

Forum|alt.badge.img
  • Author
  • Best Answer
  • August 14, 2014
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'>

david_r
Celebrity
  • August 14, 2014
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

Forum|alt.badge.img
  • Author
  • August 14, 2014
Thats right, thank you for this shortcut.