解析osm和overpass json
osm2geojson的Python项目详细描述
osm2geojson
解析osm并用python跨越json。 此库正在开发中!
使用量
使用pip安装此软件包:
$ pip install osm2geojson
如果要将osm xml或overpass json/xml转换为geojson,可以导入此库并使用以下两种方法之一:
json2geojson(dict json_from_overpass)
-将overpass json转换为geojsonxml2geojson(str xml_from_osm)
-将osm xml或overpass xml转换为geojson
示例:
importcodecsimportosm2geojsonwithcodecs.open('file.osm','r',encoding='utf-8')asdata:xml=data.read()geojson=osm2geojson.xml2geojson(xml)# >> { "type": "FeatureCollection", "features": [ ... ] }
发展
使用子模块克隆项目
$ git clone --recurse-submodules https://github.com/eos-vision/osm2geojson.git
安装包
$ python setup.py develop
运行测试
$ python -m unittest discover
将OSM多边形功能更新到最新版本(如果需要最新版本)
$ ./update-osm-polygon-features.sh