How to generate encoded polylines from shapefile/ kml?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 19:15:55

问题


I need to convert a shapefile/ kml to encoded polyline format for a certain project. Does anyone know of a simple conversion tool or code that achieves the same ?


回答1:


You'll first want to convert your KML/SHP to a list of lat/long pairs. For KML, you can simply open the KML file in an editor to get the lat/long pairs. For SHP, you can first use shp2kml to convert to KML.

Then, use the encoding library in the Maps API, or you can write your own encoder using the algorithm.




回答2:


Your term shapefile/kml is confusing. If you want to convert from an ESRI shapefile to a kml file, the utility ogr2ogr works like this:

 ogr2ogr -f "KML" outputfile.kml sourcefile.shp.

For downloads, ogr2ogr is part of the GDAL distribution: http://www.gdal.org/



来源:https://stackoverflow.com/questions/9242988/how-to-generate-encoded-polylines-from-shapefile-kml

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