How can I plot polygons with different colors using KMLWRITELINE in Mapping Toolbox 3.7 (R2013a)?
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    MathWorks Support Team
    
 el 25 de Oct. de 2013
  
    
    
    
    
    Respondida: MathWorks Support Team
    
 el 25 de Oct. de 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?
Respuesta aceptada
  MathWorks Support Team
    
 el 25 de Oct. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Google Earth en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
