Young87

SmartCat's Blog

So happy to code my life!

游戏开发交流QQ群号60398951

当前位置:首页 >跨站数据测试

wkt convert osmosis .poly ( PolygonFilter input )

MULTIPOLYGON WKT 数据地址 21523.txt

Osmosis/Polygon Filter File Format

wkt 转 poly

import sys
import numpy as np

for ipath in sys.argv[1:]:
    if not ipath.endswith('.txt'):
        print(f'skip {ipath}')
    opath = f'{ipath}.poly'
    print(opath)
    with open(ipath) as f:
        text = f.read()
    with open(opath, 'w') as f:
        f.write('geofence\n')
        cols = text.split('(')
        for idx, col in enumerate(cols):
            if len(col) < 100:
                continue
            f.write(f'area{idx}\n')
            coords = np.array([[float(x) for x in lla.split()] for lla in col[:-6].split(',')])
            for c in coords:
                f.write(f'    {c[0]} {c[1]}\n')
            f.write('END\n')
            # print(coords)
        f.write('END\n')
    print(f'wrote to {opath}')

输出 21523.txt.poly

开始过滤数据

 osmosis 
 --read-xml file="msd.osm"
 --bounding-polygon file="21523.txt.poly" completeWays="yes" clipIncompleteEntities="true" 
 --write-xml file="21523.osm"

从 msd.osm 中以 21523.txt.poly 为 boundary 过滤出了高亮部分的 osm 数据
在这里插入图片描述

除特别声明,本站所有文章均为原创,如需转载请以超级链接形式注明出处:SmartCat's Blog

上一篇: 云边协同加速AI新基建,百度智能云TechDay秀出边缘计算硬实力

下一篇: 自制板载ST-LINKV2-1下载器

精华推荐