Reputation: 629
I have latitude, longitude, and speed data. I want to plot this onto a roadmap and get a 3D plot. The roadmap can be just like google maps. I looked into openstreetmap, and they are pretty too. I want to get this plot in a figure.
Also after seeing meshc
, and surfc
, it would be much better to have the road map on the lower surface and have other data above. It will look like the projection of a trip on the map.
I have found function in the link here which uses google maps to plot on a figure. By using this and using plot3
command in matlab I was able to plot the speed. However the figure is 2D and looking from top. Whenever I use 3D rotate
and rotate the figure to see the speed, the google map disappears.
For those of you who want to help me with this issue I include a sample data in matlab .mat format. Columns are: [lon lat speed]
.It can be downloaded at this link.
Also, if any of you can point a way to save at least some portion (a region) of a roadmap database so that we can call the map directly from there that would be very good. But if that is not possible and these maps can only be fetched online that's fine too.
Below is my code of what I did with the above toolbox. I just followed the sample in the link and added the speed as a third dimension.
Thank you in advance!
load X.mat
lonlat = [];
lonlat(:,1) = X(:, 1);
lonlat(:,2) = X(:, 2);
speed = X(:, 3);
figure
plot(lonlat(:, 1), lonlat(:, 2), 'r', 'LineWidth', 2);
% Put a begin and end marker
line(lonlat(1, 1), lonlat(1, 2), 'Marker', 'o', ...
'Color', 'b', 'MarkerFaceColor', 'b', 'MarkerSize', 10);
line(lonlat(end, 1), lonlat(end, 2), 'Marker', 's', ...
'Color', 'b', 'MarkerFaceColor', 'b', 'MarkerSize', 10);
hold on
plot3(lonlat(:,1),lonlat(:,2), speed);
plot_google_map('maptype', 'roadmap');
Upvotes: 0
Views: 2925
Reputation: 636
I'm the author of plot_google_map. I tried playing around with my function to support the 3d case. You can replace the following line:
h = image(lonVect,latVect,uniImag, 'Parent', axHandle);
with:
h = surf(lonVect,latVect,zeros(length(latVect), length(lonVect)), uniImag, 'EdgeColor', 'none', 'FaceLighting', 'flat', 'EdgeLighting', 'none', 'Parent', axHandle);
This theoretically does what you want, but results in a very slow responding figure, which I'm not sure is really usable, since 3D navigation in MATLAB figures is very unnatural.
If you think this mode is usable, let me know and I'll add it to the main code.
Upvotes: 2