Thursday, June 18, 2020

SVG2GeoJSON - SVG file with added Geo-Referencing


Recently, I had a task to convert an SVG image map into GeoJSON format for use in the GIS. This is a complicated thing to do because SVG vector images don't have spatial reference.

Fortunately, I stumbled on this NodeJS app package named svg2geojson written by Prognoz. This library converts an SVG image to a (slightly-incorrect) GeoJSON


To make use of this library, you need to update your SVG map by placing two 'GeoItems' inside a Prognoz MetaInfo element as a direct child of the '<svg>' element at the root of your document.

Now how do you find the X/Y and Longitude/Latitude attributes within the 'GeoItems' for your specific SVG image? This question is what I will attempt to answer in this blog post.

The svg2geojson documentation says: "These map opposing X/Y corners in your SVG coordinate space to Longitude/Latitude coordinates on the world. Note that the SVG coordinate space has Y increasing down (toward the south), while Latitude increases upwards (towards the north)."

That is something like the daigram below:-



This for the basis of getting the X/Y coordinated from your SVG image space and the corresponding Longitude/Latitude coordinated from your GIS map.


Example: coming soon...







No comments:

Post a Comment