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?
4 Answers
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.

- 88,616
- 93
- 252
- 370
-
1I would prefer to avoid hacking it. But it is an alternative, thanks! – nauti Mar 09 '15 at 19:15
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
-
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
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.

- 411
- 5
- 14