How can I plot polygons with different colors using KMLWRITELINE in Mapping Toolbox 3.7 (R2013a)?

3 ビュー (過去 30 日間)
I am using KMLWRITELINE to make KML files showing muliptle polygons. I separate those polygons using NaN values. However, all those polygons are the same color. Is there a way to make a KML with polygons of different colors?

採用された回答

MathWorks Support Team
MathWorks Support Team 2013 年 10 月 25 日
A simple solution is to create a geoshape object to hold your data and then specify a color for each segment with the existing KMLWRITELINE interface. You would use the function POLYSPLIT which returns the NaN-delimited segments of the input vectors.
Here is an example that shows how to do that:
>> lat = [1:3 NaN 4:6 NaN 7:9];
>> lon = [1:3 NaN 4:6 NaN 7:9];
>> [latcell, loncell] = polysplit(lat, lon);
>> S = geoshape(latcell, loncell); % Creates a geoshape with 3 features, one for each line segment
>> kmlwrite(filename, S, 'Color', {'r', 'g', 'b'})
or
kmlwrite(filename, S, 'Color', [1,0,0;0,1,0;0,0,1])
where 'filename' is the names of your KML file (e.g: 'myKMLfile.kml').
Additional information about the function POLYSPLIT can be found by executing the following at the MATLAB prompt:
>> doc polysplit

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGoogle Earth についてさらに検索

製品


リリース

R2013a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by