How to load multiple gpx or xlsx/.csv files and run them individually on openstreetmap?
2 次查看(过去 30 天)
显示 更早的评论
I have two .gpx or .xlsx/.csv files attached herewith and I want to load them and run them individually on openstreetmap. I would also like to show blinking at their initial and final destination. I tried out with the following codes:
name = 'openstreetmap'; % Using openstreetmap tool
url = 'https://a.tile.openstreetmap.org/${z}/${x}/${y}.png';
copyright = char(uint8(169));
attribution = copyright + "OpenStreetMap contributors";
addCustomBasemap(name,url,'Attribution',attribution)
data=readtable("Data1.csv")
data=readtable("Data2.csv")
% Route plotting
zoomLevel = 14; % Maximum upto 25
player = geoplayer(data.latitude(1),data.longitude(1),zoomLevel);
plotRoute(player,data.latitude,data.longitude);
% Movement of vehicle on the route
player.Basemap = 'openstreetmap';
plotRoute(player,data.latitude,data.longitude);
for i = 1:length(data.latitude)
plotPosition(player,data.latitude(i),data.longitude(i))
end
Thank you, indeed.
0 个评论
回答(1 个)
Vatsal
2024-3-14
Hi,
It appears that the current approach to loading multiple .gpx or .xlsx/.csv files for individual processing on 'OpenStreetMap' results in the "data" variable being overwritten upon reading "Data2.csv". Consequently, only the route for "Data2.csv" is plotted.
To ensure each file is loaded and processed individually, the code can be adjusted to manage each file separately.
Below is an example of how this adjustment can be made:
% Define the basemap
name = 'openstreetmap';
url = 'https://a.tile.openstreetmap.org/${z}/${x}/${y}.png';
copyright = char(uint8(169));
attribution = copyright + "OpenStreetMap contributors";
addCustomBasemap(name,url,'Attribution',attribution)
% Define the zoom level
zoomLevel = 14;
% List of data files
dataFiles = ["Data1.csv", "Data2.csv"];
% Loop over each data file
for k = 1:length(dataFiles)
% Read the data
data = readtable(dataFiles(k));
% Create a geo player
player = geoplayer(data.latitude(1),data.longitude(1),zoomLevel);
player.Basemap = 'openstreetmap';
% Plot the route
plotRoute(player,data.latitude,data.longitude);
% Plot the movement of vehicle on the route
for i = 1:length(data.latitude)
plotPosition(player,data.latitude(i),data.longitude(i))
end
end
I hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Other Formats 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!