how can i convert wkb to wkt form ...
i stored coordinates in wkb but now can it will display to use in wkt form
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
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);
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:
import com.vividsolutions.jts.io.WKBReader; import com.vividsolutions.jts.geom.Geometry; 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);
In Sql Server Spatial
# load packages library(rgeos) library(wkb) # 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)
If you don't want to install any tools, online conversions between WKB, WKT and GeoJSON formats can be performed here.