How can I plot polygons with different colors using KMLWRITELINE in Mapping Toolbox 3.7 (R2013a)?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 25 Oct 2013
Réponse apportée : MathWorks Support Team
le 25 Oct 2013
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?
Réponse acceptée
MathWorks Support Team
le 25 Oct 2013
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Google Earth dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!