4

Is there a way to convert SVG files, e.g: World_map_-_low_resolution.svg into a GeoJSON which then can be loaded into Leaflet as a polygon?

nauti
  • 1,396
  • 3
  • 16
  • 37

4 Answers4

4

Want to know something cool? When Leaflet creates a polygon, it is an SVG. So try adding this SVG directly to the DOM in one of the Leaflet panes.

Jake Wilson
  • 88,616
  • 93
  • 252
  • 370
2

You could use Inkscape to convert to DXF which can then be loaded into QGIS but it's really hard to do well because of all the complications:

Reference: QGis: How to import svg or raster images into Quantum GIS?

Why not use an open source GeoJSON file of the world boundaries like https://github.com/johan/world.geo.json/blob/master/countries.geo.json or if you need higher detail the natural earth vectors found here:https://github.com/nvkelso/natural-earth-vector/tree/master/geojson

Community
  • 1
  • 1
iH8
  • 27,722
  • 4
  • 67
  • 76
  • Thank you for the geojson link, that really helps! However, in the future I need to parse a bmp file to svg and then make a geojson out of it. – nauti Mar 09 '15 at 08:20
0

You can use svg-to-json for converting your SVG to JSON. https://github.com/stela5/svg2json. I am not sure if this returns a GeoJSON but you could always parse the output of svg2json and create a valid GeoJSON out of it.

Ganesh Iyer
  • 411
  • 5
  • 14
0

This converter tool can be pretty useful: mygeodata.cloud

user2752173
  • 470
  • 1
  • 6
  • 10