Main Content

Display Vector Data as Points and Lines

This example shows how to display vector data on an axesm-based map using points and lines. axesm-based maps enable you to display geographic data using a map projection.

Load a MAT-file containing the coordinates of global coastlines into the workspace. The variables within the MAT-file, coastlat and coastlon, specify numeric latitude and longitude coordinates.

load coastlines

Set up a map using the Mollweide projection. Customize the color and line width of the frame.

figure
axesm mollweid
framem("FEdgeColor","b","FLineWidth",0.5)

Display the coastline data by using the plotm function. Customize the thickness and color of the line.

plotm(coastlat,coastlon,"LineWidth",1,"Color","b")

Specify the locations of three cities (Cairo, Rio de Janeiro, and Perth). Plot red star markers at those locations.

citylat = [30 -23 -32]; 
citylon = [32 -43 116];
plotm(citylat,citylon,"r*")

Figure contains an axes object. The axes object contains 3 objects of type patch, line.

Find the coordinates of two tracks and display them on the map.

  • Display a great circle track from Cairo to Rio de Janeiro using a dashed magenta line.

  • Display a rhumb line track from Cairo to Perth using a solid black line.

[gclat,gclon] = track2("gc",citylat(1),citylon(1),citylat(2),citylon(2));
plotm(gclat,gclon,"m--")

[rhlat,rhlon] = track2("rh",citylat(1),citylon(1),citylat(3),citylon(3));
plotm(rhlat,rhlon,"k")

Figure contains an axes object. The axes object contains 5 objects of type patch, line.

Alternatively, you can plot geographic data over axesm-based maps by using the geoshow function.

Tips

  • To plot data that is already in projected coordinates, use a regular axes object and the mapshow function.

  • You can create a similar plot by using geographic axes and the geoplot function. Geographic axes enable you to specify basemaps, change the geographic limits, and interactively pan and zoom. The geoplot function displays data into a Web Mercator map projection.

figure
geoplot(coastlat,coastlon,"b")
hold on
geoplot(citylat,citylon,"*r")
geoplot(gclat,gclon,"m--",rhlat,rhlon,"k")
geobasemap topographic
geolimits([-72 85],[-180 180])

Figure contains an axes object. The axes object contains 4 objects of type line.

See Also

Functions

Properties

Related Topics