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

What is the best way to programatically convert WKT String to GML String? Every reasonable library (at best available in some Maven repository) can be used.

Till now I came up with this solution using JTS. Its written in Java:

public String wktToGml(String wktGeometry) {
   WKTReader wktR = new WKTReader();
   Geometry geom =;

   // write JTS to string
   GMLWriter gmlW = new GMLWriter(true);
   String gml = gmlW.write(geom);
   return gml;

But I'm not sure if it's correct and most effective way. There are probably some problems with LF (linefeed) symbols. Probably there should be also solution using geotools library.

I'm new to this field, I'm trying to gain some overview.

share|improve this question
do you want a full GML document or just the gml:Polygon (or whatever) fragment? – iant Mar 8 '13 at 10:07
probably just gml:Polygon – Infragile Mar 8 '13 at 10:12
then you are probably fine with what you have – iant Mar 8 '13 at 10:21

Your Answer


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

Browse other questions tagged or ask your own question.