简体   繁体   中英

Matlab Google Earth Toolbox to export kml files in batch

I was running a loop to create separate kml files (from hundreds of point data files) using matlab googleearth toolbox's ge_scatter function as follows:

files = dir('*.txt');
for k = 1:numel(files)
Data = load(files(k).name);
x = Data(:,1);
y = Data(:,2);
kmlStr = ge_scatter(x,y);
ge_output(files(k).name,[kmlStr])
end

Unfortunately, using files(k).name doesn't give an output (with the same name in the text file) because the conventional way is to write:

ge_output('filename.kml',[kmlStr])

But in this case, the output file is replaced each time the loop runs. Could anyone please tell me how to run the loop so that I get outputs with respective file names?

Thanks for your help!

Assume that the file name at the output that you want to use is myFile . Here is what you can do:

files = dir('*.txt');
for k = 1:numel(files)
    Data = load(files(k).name);
    x = Data(:,1);
    y = Data(:,2);
    kmlStr = ge_scatter(x,y);
    ge_output(['myFile' num2str(k) '.kml'],[kmlStr])
end

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM