Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
svg to geojson approach
// svg file detail
var width = 400;
var height = 400;
// svg file spatial extent, you should know these values for your file
var extent = {left: -180, bottom: 90, right: 180, top: 90};
var x_res = (extent.left - extent.right) / width;
var y_res = (extent.left - extent.right) / height;
// x_res and y_res should be same
// for each x,y value of svg element in svg file extract the path coordinate
long = extent.left + ele_x1 * x_res;
lat = extent.top - ele_y1 * y_res;
// these coordinates can be placed in geojson accirding to the svg element type
// svg line -> LineString
// svg rectangle -> Polygon
// svg polygon -> Polygon
// svg path (if closed) > Polygon
// circle -> Point
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.