write multiple tracks to kml from a data structure
Mostra commenti meno recenti
Hi,
I have created a data structure of storm track data from a .csv file with a loop in matlab. So I now have a row for each storm and associated lat and long coords. I've used kmlwrite to generate the tracks no problem.
However, I woudl like to create a .kml of points (one set per row, see below) where the decsription for each point is the ISOTime (I converted to strings as the first error was that ISOTiem was not the correct data type).
I can't figure out how to do this as the only Mathworks examples I can find plot only one series of points (e.g. city locations), not multiple sets (rows) of points.
thanks in advance

1 Commento
david malins
il 6 Ott 2022
Risposte (1)
Piyush Dubey
il 6 Set 2023
In my understanding you are trying to create a data structure using storm track data from a ‘.csv’ file in MATLAB. ‘kmlwrite’ is being used to generate the tracks but the issue arises when you want to create a ‘.kml’ file for all the points. Another error that arises is, “The parameter/value inputs must be pairs”.
Please know that while writing geographical data in ‘.kml’ files the ‘kmlwrite’ or ‘kmlwriteline’ function expects a pair of ‘latitude’ and ‘longitude’ where each of these should be of the data type ‘int’ or ‘double’.
Please refer to the code snippet below where a sample structure is created and using for loops the data is being written to ‘.kml’ file:
stormData = struct('Latitude',[], 'Longitude',[],'ISOTime',[]);
stormData.Latitude = [10.345 234.34 343.232];
stormData.Longitude = [10.345 234.34 343.232];
stormData.ISOTime =['2018-06-25 11:23:37.712', '2019-06-25 11:23:37.712', '2020-06-25 11:23:37.712'];
% Loop through each storm track in the stormData structure array
for i = 1:numel(stormData)
% Extract the latitude and longitude coordinates for the current storm track
lat = stormData.Latitude(i);
lon = stormData.Longitude(i);
isoTime = stormData.ISOTime(i);
kmlwriteline('track.kml', lat, lon, ...
'Description', isoTime, 'Name', 'Track Log');
end
The above written code demonstrates the use of ‘kmlwriteline’ function. Please refer to the following MathWorks documentation links for more information on ‘kmlwrite’ and ‘kmlwriteline’ functions:
Hope this helps.
Categorie
Scopri di più su Standard File Formats in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!