How to convert from D3 svg to topojson/geojson?

故事扮演 提交于 2019-12-12 14:53:29

问题


D3 allows to convert geojson/topojson arrays of points' coordinates

[ [x,y],[x,y],[x,y],...]    // aka, a geojson arc.

And, via a projection, into svg paths

<path d="M x,y x,y x,y ..."></path>  // aka, an svg-xml path

Note: the values actually change. Points [x,y] in topojson, get new valued via projection([x,y]) for svg's path.

So, if we store in the svg:

  1. the projection name

  2. the points absolute coordonates relative to the svg origine 0,0 (already stored in the path).

  3. Use projection.invert()

We could convert from xml back into topojson/shp, including hand added shapes.

I am unaware so far of any open source tool doing so.

Question become: What minimal requirements should i store in my svg so it keep the potential to be converted back into gis formats ? (i may have missed some points)


Edit: While aware about it, the complexity of handling Point, LineString, Polygon, MultiPoints, MultiLineStrings, MultiPolygons is not the issue right now. Just the minimal requirements so backward conversion stays possible.

Edit2: convert back to geojson would likely be easier, since the svg and geojson data structures are more similar.

来源:https://stackoverflow.com/questions/28266721/how-to-convert-from-d3-svg-to-topojson-geojson

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!