Main Content

plot

Plot HERE HD Live Map layer data

Description

example

plot(layerData) plots HERE HD Live Map 1 (HERE HDLM) layer data on a geographic axes. layerData is a map layer object that was read from the selected tiles of a hereHDLMReader object by using the read function.

example

plot(layerData,'Axes',gxIn) plots the layer data in the specified geographic axes, gxIn.

example

gxOut = plot(___) plots the layer data and returns the geographic axes on which the data was plotted, using the inputs from any of the preceding syntaxes. Use gxOut to modify properties of the geographic axes.

Examples

collapse all

Load a sequence of latitude and longitude coordinates from a driving route.

data = load("geoSequence.mat")
data = struct with fields:
     latitude: [1000×1 double]
    longitude: [1000×1 double]

Create a HERE HD Live Map (HERE HDLM) reader from the specified coordinates. If you have not previously set up HERE HDLM credentials, a dialog box prompts you to enter them. The reader contains layered map data for the tile that the driving route is on.

reader = hereHDLMReader(data.latitude,data.longitude);

Read road topology data from the TopologyGeometry layer. Plot the data.

roadTopology = read(reader,"TopologyGeometry");
plot(roadTopology)
legend("Location","northeastoutside")

Figure contains an axes object with type geoaxes. The geoaxes object contains 3 objects of type line. One or more of the lines displays its values using only markers These objects represent Boundaries, Nodes, Links.

Overlay the driving route coordinates on the plot.

hold on
geoplot(data.latitude,data.longitude,"bo-","DisplayName","Route")
hold off

Figure contains an axes object with type geoaxes. The geoaxes object contains 4 objects of type line. One or more of the lines displays its values using only markers These objects represent Boundaries, Nodes, Links, Route.

Zoom in on the route.

latcenter = median(data.latitude);
loncenter = median(data.longitude);

offset = 0.005;
latlim = [latcenter-offset,latcenter+offset];
lonlim = [loncenter-offset,loncenter+offset];

geolimits(latlim,lonlim)

Figure contains an axes object with type geoaxes. The geoaxes object contains 4 objects of type line. One or more of the lines displays its values using only markers These objects represent Boundaries, Nodes, Links, Route.

Use the HERE HD Live Map (HERE HDLM) service to read the lane topology data of a driving route and its surrounding area. Plot this data, and then stream the route on a geographic player.

Load the latitude and longitude coordinates of a driving route in Natick, Massachusetts, USA.

route = load('geoSequenceNatickMA.mat');
lat = route.latitude;
lon = route.longitude;

Stream the coordinates on a geographic player.

player = geoplayer(lat(1),lon(1),'HistoryDepth',5);
plotRoute(player,lat,lon)

for idx = 1:length(lat)
    plotPosition(player,lat(idx),lon(idx))
end

Figure Geographic Player contains an axes object with type geoaxes. The geoaxes object contains 5 objects of type line, scatter, text. One or more of the lines displays its values using only markers

Create a HERE HDLM reader from the route coordinates. If you have not previously set up HERE HDLM credentials, a dialog box prompts you to enter them. The reader contains map data for the two map tiles that the route crosses.

reader = hereHDLMReader(lat,lon);

Read lane topology data from the LaneTopology layer of the map tiles. Plot the lane topology.

laneTopology = read(reader,'LaneTopology');
plot(laneTopology)

Figure contains an axes object with type geoaxes. The geoaxes object contains 3 objects of type line. These objects represent Boundaries, Lane Group Connectors, Lane Groups.

Overlay the route data on the plot.

hold on
geoplot(lat,lon,'bo-','DisplayName','Route');
hold off

Figure contains an axes object with type geoaxes. The geoaxes object contains 4 objects of type line. These objects represent Boundaries, Lane Group Connectors, Lane Groups, Route.

Overlay the lane topology data on the geographic player. Stream the route again.

plot(laneTopology,'Axes',player.Axes)
for idx = 1:length(lat)
    plotPosition(player,lat(idx),lon(idx))
end

Figure Geographic Player contains an axes object with type geoaxes. The geoaxes object contains 8 objects of type line, scatter, text. One or more of the lines displays its values using only markers These objects represent Boundaries, Lane Group Connectors, Lane Groups.

Use the HERE HD Live Map (HERE HDLM) web service to read 3-D lane geometry data from a map tile. Then, plot the 2-D part of the data on an OpenStreetMap® basemap.

Create a HERE HDLM reader for a map tile ID representing an area of Berlin, Germany. If you have not previously set up HERE HDLM credentials, a dialog box prompts you to enter them.

tileID = uint32(377894435);
reader = hereHDLMReader(tileID);

Add the OpenStreetMap basemap to the list of basemaps available for use with the HERE HDLM service. After you add the basemap, you do not need to add it again in future sessions.

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)

Read 3-D lane geometry data from the LaneGeometryPolyline layer of the map tile. Plot the 2-D part of the lane geometry on the openstreetmap basemap.

laneGeometryPolyline = read(reader,'LaneGeometryPolyline');
gx = plot(laneGeometryPolyline);
geobasemap(gx,'openstreetmap')

Zoom in on the central coordinate of the map tile.

latcenter = laneGeometryPolyline.TileCenterHere3dCoordinate.Here2dCoordinate(1);
loncenter = laneGeometryPolyline.TileCenterHere3dCoordinate.Here2dCoordinate(2);

offset = 0.001;
latlim = [latcenter-offset,latcenter+offset];
lonlim = [loncenter-offset,loncenter+offset];

geolimits(latlim,lonlim)

Since R2023a

Set the default basemap for plots created from HERE HD Live Map layer data.

Add HERE Basemap

Add a basemap from HERE to the list of basemaps available for use with mapping functions. To add a HERE basemap, you must have a valid license from HERE.

Specify the basemap name and map URL.

name = "herestreets";
url = "https://1.base.maps.ls.hereapi.com/maptile/2.1/maptile/" + ...
    "newest/normal.day/${z}/${x}/${y}/256/png?apikey=%s";

Create a dialog box. In the dialog box, enter the Access Key ID corresponding to your HERE license.

prompt = "HERE Access Key ID:";
title = "HERE Tokens";
dims = [1 40]; % Text edit field height and width
hereTokens = inputdlg(prompt,title,dims);

HERE Tokens dialog box

Add the basemap using the map URL, the Access Key ID, and a custom attribution. After you add the basemap, you do not need to add it again in future sessions.

url = sprintf(url,hereTokens{1});
copyrightSymbol = char(169); % Alt code
yr = string(datetime("today",Format="yyyy"));
attribution = copyrightSymbol + yr + " HERE";
addCustomBasemap(name,url,"Attribution",attribution)

Specify Basemap as Default Basemap

MATLAB® stores the default basemap for plots created from HERE HD Live Map layer data in the MATLAB settings tree. Set the personal value for the default basemap to the HERE basemap. The personal value persists across MATLAB sessions for an individual user.

s = settings;
s.driving.heremaps.Basemap.PersonalValue = "herestreets";

Plot Data

Load a sequence of latitude and longitude coordinates from a driving route in Natick, Massachusetts, USA.

route = load("geoSequenceNatickMA.mat");
lat = route.latitude;
lon = route.longitude;

Create a HERE HD Live Map reader from the route coordinates. If you have not previously set up HERE HD Live Map credentials, a dialog box prompts you to enter them. The reader contains map data for the two map tiles that the route crosses.

reader = hereHDLMReader(lat,lon);

Read 3-D lane geometry data from the LaneGeometryPolyline layer of the map tile. Plot the 2-D part of the lane geometry on a geographic axes. Note that the geographic axes uses the HERE basemap.

laneGeometryPolyline = read(reader,"LaneGeometryPolyline");
plot(laneGeometryPolyline)

Figure contains an axes object. The axes object contains 4 objects of type line. These objects represent Boundaries, Lane Group Reference, Lane Paths, Lane Boundaries.

Reset Default Basemap

Clear the personal value of the basemap setting, restoring the default basemap to the factory value.

clearPersonalValue(s.driving.heremaps.Basemap)

For more information about changing MATLAB settings, see Access and Modify Settings.

Input Arguments

collapse all

HERE HDLM layer data to plot, specified as one of the layer objects shown in the table.

Layer ObjectDescriptionSample Plot
LaneGeometryPolyline

3-D lane geometry composed of a set of 3-D points joined into polylines.

LaneGeometryPolyline plot with boundaries, lane group reference, lane paths, and lane boundaries

LaneTopology

Topologies of the HD Lane model, including lane group, lane group connector, lane, and lane connector topologies. This layer also contains the simplified 2-D boundary geometry of the lane model for determining map tile affinity and overflow.

LaneTopology layer with boundaries, lane group connectors, and lane groups

TopologyGeometry

Topology and 2-D line geometry of the road. This layer also contains definitions of the links (streets) and nodes (intersections and dead-ends) in the map tile.

TopologyGeometry layer with boundaries, nodes, and links

To obtain these layers from map tiles selected by a hereHDLMReader object, use the read function.

Geographic axes on which to plot data, specified as a GeographicAxes object.2

Output Arguments

collapse all

Geographic axes on which data is plotted, returned as a GeographicAxes object. Use this object to customize the map display. For more details, see GeographicAxes Properties.

Version History

Introduced in R2019a


1 You need to enter into a separate agreement with HERE in order to gain access to the HDLM services and to get the required credentials (access_key_id and access_key_secret) for using the HERE Service.

2 Alignment of boundaries and region labels are a presentation of the feature provided by the data vendors and do not imply endorsement by MathWorks®.