plot
Plot HERE HD Live Map layer data
Description
plot(
plots HERE HD Live Map
1
(HERE HDLM) layer data on a geographic axes. layerData
)layerData
is
a map layer object that was read from the selected tiles of a hereHDLMReader
object by using the read
function.
Examples
Plot Road Topology Data from Driving Route
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")
Overlay the driving route coordinates on the plot.
hold on geoplot(data.latitude,data.longitude,"bo-","DisplayName","Route") hold off
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)
Plot and Stream Lane Topology Data from Driving 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
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)
Overlay the route data on the plot.
hold on geoplot(lat,lon,'bo-','DisplayName','Route'); hold off
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
Plot 2-D Lane Geometry on Custom Basemap
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)
Set Default Basemap for Plots Created from Layer Data
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);
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)
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
layerData
— HERE HDLM layer data
LaneGeometryPolyline
object | LaneTopology
object | TopologyGeometry
object
HERE HDLM layer data to plot, specified as one of the layer objects shown in the table.
Layer Object | Description | Sample Plot |
---|---|---|
LaneGeometryPolyline | 3-D lane geometry composed of a set of 3-D points joined into polylines. |
|
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. |
|
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. |
|
To obtain these layers from map tiles selected by a hereHDLMReader
object, use the read
function.
gxIn
— Geographic axes on which to plot data
GeographicAxes
object
Geographic axes on which to plot data, specified as a
GeographicAxes
object.2
Output Arguments
gxOut
— Geographic axes on which data is plotted
GeographicAxes
object
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
See Also
hereHDLMReader
| geoplayer
| geoaxes
| geoplot
| geobasemap
| read
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®.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)