11

I have some Well-known text (WKT) for representing geometry object such as Point, MultiPoint, LineString, Polygon, MultiPolygon etc. I have a multipolygon with in total 40000 Points.

I have found this plugin to convert SVG to WKT. Is there any JavaScript or PHP plugin which converts WKT to SVG?

Gottlieb Notschnabel
  • 9,408
  • 18
  • 74
  • 116
Jetson John
  • 3,759
  • 8
  • 39
  • 53
  • Time to write one :3 For time being, I found this: http://dev.openlayers.org/sandbox/docs/examples/wkt.html seems to work only on Chrome... – rr- May 29 '14 at 08:24

5 Answers5

1

Use Wellknown to convert WKT to GeoJSON, then use D3 to convert GeoJSON to SVG.

Source : A comment to the same question you asked here : https://gis.stackexchange.com/questions/72323/how-to-convert-wkt-to-svg

Community
  • 1
  • 1
Tim Nguyen
  • 1,163
  • 10
  • 21
1

I know its been a long time but you could write one. a conversion between those two is fairly simple.

for example the following simple function converts a WKT polygon

    var s = data.split("POLYGON ((");
    var s2 = s[1].substring(0, s[1].length - 2).split(" ");

    var mysvg = "M";
    for (var i = 0; i < s2.length - 2; i += 2) {
        mysvg += (s2[i].substring(0, s2[i].length - 1)) + ",";
        mysvg += (s2[i + 1].substring(0, s2[i + 1].length - 1)) + "L";
    }
    mysvg = mysvg.substr(0, mysvg.length - 1) + "z";
elasticrash
  • 1,181
  • 1
  • 12
  • 30
1

You might take a slightly longer trip in your conversion, using MapBox's wellknown library to convert WKT to GeoJSON and then use D3 to display the GeoJSON as SVG Path element(s).

SomethingDark
  • 13,229
  • 5
  • 50
  • 55
Trifactor
  • 59
  • 9
1

Using MapBox's wellknown library to convert WKT to GeoJSON and then use D3 to display the GeoJSON as SVG Path element(s).

Abhishek
  • 674
  • 6
  • 9
0

libnfporb has a command-line tool to convert wkt to svg: https://github.com/kallaballa/libnfporb/blob/master/examples/wkt_to_svg.cpp

you need to build the library to use it.

usage: ./wkt_to_svg some.wkt some.svg

(I am the author of libnfporb)

kallaballa
  • 337
  • 2
  • 8