some issues related to write kml files

18 visualizzazioni (ultimi 30 giorni)
lang
lang il 19 Ott 2025 alle 7:36
I have encountered an issue regarding the ordering of polygon vertices and writing to KML files. As demonstrated in the following code, I need to convert the polygon vertices to a counterclockwise order ([lonb, latb] = poly2ccw(lonb, latb); this is mandated by some data services). However, the output KML file appears somewhat strange (Figure 2). How can I obtain a KML file similar to Figure 1? I have limited knowledge in this area, and any advice would be greatly appreciated.
% load coastline
load('coast_polygon_c.mat', 'lonb', 'latb');
% check direction
ispolycw(lonb, latb)
ans = 4×1 logical array
1 0 0 0
% plot
shape = geopolyshape(latb, lonb);
shape.GeographicCRS = geocrs(4326);
figure;geoplot(shape);
% convert to counter-clockwise
[lonb, latb] = poly2ccw(lonb, latb);
% save and write kml
kmlwritepolygon('coast_polygon_c.kml', latb, lonb);
% plot
GT=readgeotable('coast_polygon_c.kml');
figure;geoplot(GT);

Risposte (0)

Categorie

Scopri di più su Geographic Plots in Help Center e File Exchange

Prodotti


Release

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by