How to Convert SVG to SHP (Shape File) format?

user1517745 picture user1517745 · Dec 26, 2012 · Viewed 9.8k times · Source

I am trying to convert the SVG File to SHP (Shape File format) and then get it imported into GeoServer.

Is there any convertor available OR is there any mediating format in which I can get it converted and finally get it in SHP format?

I already have shape file of Map of India. Now, there are some odd 60 districts got added in recent years. New districts are separate from the old ones. So, the total area of the country has not changed, but got divided.

What I am thinking is, if I can merge the new layer which I have of new districts in SVG format to the original SHP file data and get the final coordinates mapped according to the SHP file, then the problem can be sorted.

If anyone has done it and can help, will be great!! Thanks!!

Answer

Spacedman picture Spacedman · Dec 26, 2012

Highly unlikely. SVG is a 'drawing' format, and so there's no guarantee that the lines have coordinates that are anything in the real world - they might be in centimetres based on a piece of A4-size paper.

So you would have to at least work out the transformation from those coordinates to lat-long, or some other coordinate system. This may be non-linear...

However SVG is an XML-based file, so you can open it in a text editor and get a look at it. If you can figure out what elements hold the coordinates you need, then you can write a script (I'd do it in Python, but whatever language you can program in that has XML support will do) to strip out the coordinates. Then it might be possible to think about converting them to a shapefile - or maybe GML - an XML-based standard format for geographical data.

But to be honest, it might be much easier to source a shapefile with the boundaries you want in it.