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

2 次查看(过去 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
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 CenterFile Exchange 中查找有关 Google Earth 的更多信息

产品


版本

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by