一、matlab自带函数 写kml文件
0.准备知识
(1)kmlwrite( ) 函数
(2)geoshape( )函数
(3)kmlwriteline()函数
(4)kmlwritepolygon()函数
(5)kmlwritepoint()函数
(6)shapewrite()函数
matlab 写.shp文件
1.写点文件
(1)情景:如下所示,给出若干个点的经纬度坐标,调用相关函数,设置kml文件格式: (2)geoshape默认是 线 (line):
LAT=[52.17101310,52.08006661,51.77114935,51.86161181];
LON=[126.55621819,127.06011254,126.91212965,126.41155862];
filename = 'D:\test_001_point.kml';
shape = geoshape(LAT,LON);
shape.Geometry = 'point';
kmlwrite(filename,shape,'Color','red');
结果展示:
2.写线文件
(1)绿线的轨迹走向和所给的点的经纬度顺序相对应
% 写线文件
LAT=[52.17101310,52.08006661,51.77114935,51.86161181];
LON=[126.55621819,127.06011254,126.91212965,126.41155862];
filename = 'D:\test_001_line.kml';
shape = geoshape(LAT,LON);
shape.Geometry = 'line'; % 可不要,因为geoshape默认属性为线
kmlwrite(filename,shape,'Color','green','width',2);
3.写多边形文件
(1)写多边形文件,给出点的经纬度要形成一个闭环,即第一个点和最后一个点是同一个点
% 写多边形文件
LAT=[52.17101310,52.08006661,51.77114935,51.86161181,52.17101310];
LON=[126.55621819,127.06011254,126.91212965,126.41155862,126.55621819];
filename = 'D:\test_001_polygon.kml';
shape = geoshape(LAT,LON);
shape.Geometry = 'polygon';
kmlwrite(filename,shape,'Color','yellow','width',2);
二、直接写kml文件
1.阅读了解kml文件
(1)最详细的学习博客:包括点,点描述,叠层,线,多边形 https://blog.csdn.net/alzhuzhu/article/details/52163572 (2)另外一个博客 https://blog.csdn.net/onlymydreams_mfc/article/details/81840232
2.实践写kml文件
(1)实践类博客 http://blog.sina.com.cn/s/blog_6b1c80b30102xtqa.html
python写kml文件
见: https://blog.csdn.net/weixin_43955546/article/details/123486605
|