1 ????# 输出json文件 2 ????features = [] 3 ????for line in pts: ????4 ????????(x0,y0,x1,y1) = line ?5 ?6 ????????geo = {‘type‘: ‘LineString‘, ‘coordinates‘: [ [x0, y0], [x1, y1] ] } 7 ?????????8 ????????feature = {‘type‘: ‘Feature‘, ‘geometry‘: ?geo } 9 10 ????????features.append(feature)11 12 ????geometries = {13 ????????‘type‘: ‘FeatureCollection‘,14 ????????‘features‘: features,15 ????}16 17 ????geo_str = json.dumps(geometries) 18 19 ????f = open(‘d:/temp/0000001/roads.json‘,‘w‘)20 ????f.write(geo_str)21 ????f.close()
geometries几何图形转存为geojson文件
原文地址:https://www.cnblogs.com/jobgeo/p/9674693.html