Tag: Well-Known Binary

Getting the Well-Known Binary representation of geometries using the JTS Topology Suite.

Posted by – Thursday 2010-11-25

In this post we will see how to get the Well-Known Binary[1] (WKB) representation of geometries using the Java library JTS Topology Suite. WKB is a binary, serialized form of the Well-Known Text (WKT) representation of geometries.

In the first section a sample program getting the WKB representation of two simple geometries is shown. The second section covers potential issues related with endiannesss.

1. Simple Java code

JTS Topology Suite package com.vividsolutions.jts.io provides classes to get both WKB and WKT representations of geometries. Let’s see how to get the WKB representation of a point and a polygon using them; the key class is WKBWriter.