最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Save Data to Shapefile with OpenLayers - Stack Overflow

programmeradmin1浏览0评论

I am creating a web application using OpenLayers. I have implemented functionality such that a user can add a point or polygon to the map that is displayed using JavaScript. I now need to save this data to a shapefile. Any ideas on how?

I am creating a web application using OpenLayers. I have implemented functionality such that a user can add a point or polygon to the map that is displayed using JavaScript. I now need to save this data to a shapefile. Any ideas on how?

Share Improve this question edited Nov 16, 2010 at 18:07 nix asked Nov 16, 2010 at 17:53 nixnix 4,8015 gold badges24 silver badges19 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

I know it's an old thread but I came here with the same question after doing a bit of googling myself to see if there was anything out there. I concluded that there wasn't but that there could be, so I wrote it:

https://code.google./p/js2shapefile/

It's the first time I've done anything along these lines in Javascript so I'm sure you'll find all kinds of oddities with my code...but, it works, for ESRI Javascript API graphics and Google Maps markers, at any rate. It could be easily extended to take OpenLayers vectors as input too, but I haven't got round to doing that.

You'll probably have to do it on the server, unless there's a javascript implementation of shapelib.

Actually, do you want the web user to get a shapefile to save or do you want to save it on the server?

There's lots of ways of doing it on a server, depending on your server language of choice. In python, you just import the ogr library and write it... You'll need to construct a web request from the client with the data in it though...

Maybe geoscript can help:

http://geoscriptblog.blogspot./2010/06/merging-shapefiles-with-javascript.html

There's a good overview on this issue here. For converting to shape using client side javascipt only, you could base you work on the JavaScript Shapefile to GeoJSON library.

发布评论

评论列表(0)

  1. 暂无评论