geometries幾何圖形轉存爲geojson文件

 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()
相關文章
相關標籤/搜索