How do I convert WKT geometry to EWKB/WKB?

Here's my WKT: POLYGON ((113.749421064162419 62.38697568386327,113.754636282390067 62.386872575140529,113.755323673085357 62.334314115202005,113.67332998202032 62.334365618648548,113.669425138956726 62.334440650119198,113.671148294006684 62.384794727891922,113.671538735831803 62.387549090847621,113.749421064162419 62.38697568386327))

And here's what I get using ogr's feature.GetGeometryRef().ExportToWkb():

b'\x00\x00\x00\x00\x03\x00\x00\x00\x01\x00\x00\x00\x08@\\o\xf6\x83\xc4\xb6@O1\x88kQE\x1e@\\pK\xf5\xfaOb@O1\x85\n\xf9T@\\pW9\x1ar\xf5@O*\xca\xce\x0f\xb1 @\\k\x17\xd6\xa3\x0cc@O*\xcc~\x1a\x80L@\\j\xd7\xdc\x89\xbc\x1f@O*\xce\xf3\x83[\x83@\\j\xf4\x17\xf9a\x98@O1@\xf4!\xfc\t@\\j\xfa}\x9b\x19D@O1\x9b5gd}@\\o\xf6\x83\xc4\xb6@O1\x88kQE\x1e'

The last thing seems corrupt and cannot be decoded with either ASCII or UTF-8.

Is there any way to convert shapefile's geometry to EWKB/WKB other than with PostGIS (ogr, pyshp etc.)?

closed as off-topic by Vince, user30184, Mapperz Nov 9 '16 at 15:03

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – Vince, user30184, Mapperz
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Binary is binary -- It can't be converted to UTF-8, only reformatted as hexadecimal, octal, or base64, but then it will no longer be binary, only string. – Vince Nov 9 '16 at 12:00
  • @Vince Actually, this is exactly what I want. My goal is to compare this geometry to EWKB (hex?) representation from PostGIS. So how do I convert this byte output to hexadecimal (?) EWKT PostGIS form? Here they say codec is needed anyway. – Basile Nov 9 '16 at 13:51
  • 1
    No, a codec is not needed. It's less than a dozen lines of code, but the question, "How do I format a binary array as hexadecimal ASCII?" Is off-topic for GIS SE (and probably already answered elaewhere). – Vince Nov 9 '16 at 14:33