Using Matlab Google-Earth Toolbox to plot Latitude and Longitude
Asked Answered
E

1

6

I am trying to plot some waypoints using the Google-Earth toolbox. The documentation for it is pretty poor, so I figured this would be a good Stack Overflow question.

I have a matrix, wypts that has pairs of latitude and longitude coordinates in decimal format (If anyone is wondering this over the State College Airport (SCE) in Pennsylvania).

wypts =
   40.8489  -77.8492
   40.8922  -77.8492
   40.9355  -77.8492
   40.9788  -77.8492
   41.0221  -77.8492
   41.0654  -77.8492
   41.1087  -77.8492
   41.1154  -77.8492

The following does not work instead of plotting points in Pennsylvania, it plots nothing in the off the south pole:

output = ge_plot(wypts(:,1),wypts(:,2))
ge_output('wypts.kml',output)
Encephalography answered 5/10, 2010 at 19:58 Comment(0)
P
3

You have your latitudes and longitudes mixed up. The help documentation for ge_plot says that the first input should be longitude, and the second input should be latitude. Try this:

output = ge_plot(wypts(:,2),wypts(:,1));
ge_output('wypts.kml',output);
Pitchblack answered 5/10, 2010 at 20:20 Comment(3)
And goes directly back to my point about their documentation, when is longitude ever first? :pEncephalography
@Elpezmuerto: Yeah, that's confusing, especially when you can type 40.85 -77.85 into the search bar for Google Maps and get the point you want. Not sure why they would reverse that in the toolbox.Pitchblack
Try thinking about latitude / longitude in a 2D XY projection. We normally state "X" then "Y" when plotting etc. Now a change in Longitude is a change in "X". A change in Latitude is a change in "Y". I've seen this problem in numerous places. Always look at the documentation. Never assume!Lalo

© 2022 - 2024 — McMap. All rights reserved.