在geojson中实现多边形环缠绕顺序的python库
geojson-rewind的Python项目详细描述
GeoJSON倒带
用于在geojson中强制执行多边形环形缠绕顺序的python库
规范要求right hand rule:
A linear ring MUST follow the right-hand rule with respect to the area it bounds, i.e., exterior rings are counterclockwise, and holes are clockwise.
这有助于生成兼容多边形和多多边形几何体。
安装
pip install geojson-rewind
用法
>>>input={...'geometry':{'coordinates':[[[100,0],...[100,1],...[101,1],...[101,0],...[100,0]]],...'type':'Polygon'},...'properties':{'foo':'bar'},...'type':'Feature'}>>>fromgeojson_rewindimportrewind>>>output=rewind(input)>>>importpprint>>>pp=pprint.PrettyPrinter(indent=4)>>>pp.pprint(output){'geometry':{'coordinates':[[[100,0],[101,0],[101,1],[100,1],[100,0]]],'type':'Polygon'},'properties':{'foo':'bar'},'type':'Feature'}
致谢
geojson-rewind
是mapbox的javascriptgeojson-rewind包的python端口。记入Tom MacWright和contributors。