# MATLAB: save geospatial polygons in a *.kml file

11 Ansichten (letzte 30 Tage)
Alfredo am 5 Mär. 2013
Beantwortet: Rob Comer am 14 Okt. 2021
After generating the poligons vertices and defined their faces, I've plotted the polygons with the patch function:
pp = patch('Faces',faces,'Vertices',vertices);
and then I've defined the patches colors:
set(pp,'FaceColor','flat',...
'FaceVertexCData',cdata,...
'CDataMapping','direct',...
'EdgeAlpha',.4,'EdgeColor','b')
Getting the following Matlab plot:
Now, I would like to visualize these polygons with Google Earth, but I don't know how.
I've tried the function kmlwrite, but I could pass to it only the polygons' vertices's coordinates, generating a kml file with all points and no polygon, as shown below:
The question is: wow can I write geospatial polygons (and their colors) into a .kml file with kmlwrite function?
Thanks
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Alfredo am 5 Apr. 2013
I've found the solution of my problem in the KML ToolBox:
< https://www.mathworks.com/matlabcentral/fileexchange/34694-kml-toolbox-v2-3 https://www.mathworks.com/matlabcentral/fileexchange/34694-kml-toolbox-v2-3>
in particular in the k.poly3 function.
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
T S am 10 Okt. 2017
How did you enter the 'Faces' data into the k.poly3 function? It appears to only accept X,Y,Z coordinates along with a few visual modifiers.

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (2)

Rob Comer am 28 Jan. 2020
With Mapping Toolbox and MATLAB R2016a or later, you can use the kmlwritepolygon function.
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Polsak Tothong am 14 Okt. 2021
How can we use kmlwritepolygon when input have multiple polygons. Matlab function seems to write one polygons at a time only

Melden Sie sich an, um zu kommentieren.

Rob Comer am 14 Okt. 2021
See the example Write Polygon Data to KML File on the kmlwrite reference page.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Elementary Polygons finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by