wkt convert osmosis .poly ( PolygonFilter input )
日期: 2020-10-28 分类: 跨站数据测试 451次阅读
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}')
开始过滤数据
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
标签:OSM
精华推荐