Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

how can i convert wkb to wkt form ...

i stored coordinates in wkb but now can it will display to use in wkt form

share|improve this question
Hi tina, you'll need to provide more details to make this question answerable, such as what software are you attempting to do this with, or attempting to do encoding / decoding directly? – scw Nov 24 '10 at 8:22
Consider changing the question title to "Converting WKB to WKT" – underdark Nov 24 '10 at 9:00
up vote 8 down vote accepted

If you want to use PostGIS to do the conversion, you can choose from the following functions:

bytea WKB = ST_AsBinary(geometry);
text WKT = ST_AsText(geometry);
geometry = ST_GeomFromWKB(bytea WKB, SRID);
geometry = ST_GeometryFromText(text WKT, SRID);


share|improve this answer
no i am not using any exisitng db,. i want to apply spatial db .. – tina Nov 24 '10 at 9:48
"i want to apply spatial db" - Does that mean you want to use PostGIS? Then the above functions should help. – underdark Nov 24 '10 at 9:50
This helped me solve it for SQL Server. In SQL Server the function is STAsText. – Iain Elder Aug 29 '13 at 17:58

If you can work with Java, the JTS Topology Suite can perform such translation by using the classes and com.vividsolutions.jts.geom.Geometry. A code like this should get the geometry in Well-Known Text format:

String wkbString = "0101000000cdcccccc170d2241b81e859bcb405241";
// geometry in WKB format to be translated to WKT
byte[] aux = WKBReader.hexToBytes(wkbString);
Geometry geom = new WKBReader().read(aux);
String wktString = geom.toText();
// geometry in WKT format
System.out.printf("WKB = %s\n", wkbString);
System.out.printf("WKT = %s\n", wktString);
share|improve this answer

In Sql Server Spatial

select geometry::STGeomFromWKB(0x01030000000100000005000000E968ED3E66CF1D41BD6859D5EEE15941E968ED3E66CF1D41844B22F8E1E959417156F69608241F41844B22F8E1E959417156F69608241F41BD6859D5EEE15941E968ED3E66CF1D41BD6859D5EEE15941,3857).ToString();
share|improve this answer
does this add anything that isn't in the accepted answer (from >3 years ago)? – Evil Genius Jul 14 '14 at 15:10
yeah this is basically sql server specific, the accepted answer IMHO is based on PostGIS – varun Jul 14 '14 at 19:11

Using R, you can convert between WKB and WKT using the packages rgeos and wkb. Example:

# load packages

# create raw vector representing WKB geometry
wkb <- hex2raw("0101000000cdcccccc170d2241b81e859bcb405241")

# convert WKB to Spatial object
obj <- readWKB(wkb)

# convert Spatial object to WKT
wkt <- writeWKT(obj, byid = TRUE)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.