Created
November 24, 2014 16:37
-
-
Save gagan-bansal/4d779c7d09a69345d96c to your computer and use it in GitHub Desktop.
svg to geojson approach
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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