Вопрос

Question: How do I plot GPS longitude and Latitude coordinates using the scatter or geoshow function (or whatever function works best)

Hi everyone

I have this GPS unit I'd like to analyze so I went out and tested it, got several pages of NMEA sentences (for 3 different spots on the same field) that I like to plot using Matlab's scatter function (or geoshow function...whatever works).

Since NMEA sentences give out tons of information which I don't need; I sorted through and simplified the data to contain only longitude in one file and latitude in another file (I have several spots locations).

I made both files .csv files so I could read in these files using Matlab's csvread function rather than having to manually enter these numbers manually into matrices.

The problem I have is that when I go to plot these spots I can only show 1 spot on 1 graph at a time. This really defeats the purpose of graphing the coordinates...how can I graph all 3 spots all on the same graph using the .csv files I made or any method you know of?

Here's what I've tried:

 SW_latitude = csvread('SW_latitude.csv'); 
 SW_longitude = csvread('SW_longitude.csv');

 CENTER_latitude = csvread('center_latitude.csv'); 
 CENTER_longitude = csvread('center_longitude.csv');

 WALKING_latitude = csvread('WALKING_latitude.csv'); 
 WALKING_longitude = csvread('WALKING_longitude.csv');
 scatter(SW_latitude,SW_longitude) 
 hold on
 scatter(CENTER_latitude,CENTER_longitude)
 scatter(WALKING_latitude,WALKING_longitude)
 hold off

Screen shot of one coordinate being plotted...why only just 1 dot? I should see a scatter?

Это было полезно?

Решение

1) NMEA messages often have the longitude and latitude of the format 3246.4270, 11704.3785 etc.

The two numerals before the decimal point and those after are minutes, the two/three numerals at the front are degrees, i.e. 32 degrees, 46.4270 minutes, 117 degrees, 04.3785 minutes, etc. You can convert these to decimal degrees after loading (doesn't need three lines but hopefully this makes the process clearer):

degrees = floor(lat/100); % number of degrees
minutes = lat-degrees*100; % number of minutes
lat2 = degrees + minutes/60;

2) If your values are all from within a small area, the changes in latitude and longitude will not be great. Therefore, watch your axis limits. You can set these with xlim and ylim after plotting if you know the approximate range you want to examine.

3) There is a free mapping toolbox, m_map, which I quite like. Otherwise, if using geoshow you may have to set the display type to Point. You can set the various color/marker settings as well. Take a handle when you plot and then use get and set to check what sort of settings you can adjust.

h = geoshow(lat, lon, 'DisplayType', 'Point')
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top