Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
3  
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
2  
Consider changing the question title to "Converting WKB to WKT" –  underdark Nov 24 '10 at 9:00
add comment

2 Answers

up vote 5 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);

More: http://postgis.net/docs/manual-1.5/ch04.html#OpenGISWKBWKT

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
add comment

If you can work with Java, the JTS Topology Suite can perform such translation by using the classes com.vividsolutions.jts.io.WKBReader 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
add comment

Your Answer

 
discard

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.