Main Content


Write HD Map to binary file using MATLAB

Since R2022b



    write(rrMap,filename) writes the RoadRunner HD Map in a binary file filename. Specify the extension of the file as .rrhd. You can import the file into RoadRunner by adding the file to a folder in the Library Browser and dragging it into the scene. You can then build the scene using the Scene Builder Tool (RoadRunner).

    write(rrMap,filename,Name=Value) sets options using one or more name-value arguments.


    collapse all

    Create a RoadRunner HD Map by calling the roadrunnerHDMap object. Populate the map using your custom data. For example, this code specifies the author and the spatial bounds of the geometric data attributes for the map. The call to the roadrunnerHDMap object returns a HD map with author and spatial bounds attributes.

    rrMap = roadrunnerHDMap(Author="Map Author",GeographicBoundary=[-0.782 -3.13 0;101.565 50 0])
    rrMap = 
      roadrunnerHDMap with properties:
                    Author: "Map Author"
                Projection: ""
        GeographicBoundary: [2×3 double]
                     Lanes: [0×1 roadrunner.hdmap.Lane]
            LaneBoundaries: [0×1 roadrunner.hdmap.LaneBoundary]
                LaneGroups: [0×1 roadrunner.hdmap.LaneGroup]
              LaneMarkings: [0×1 roadrunner.hdmap.LaneMarking]
                 Junctions: [0×1 roadrunner.hdmap.Junction]
              BarrierTypes: [0×1 roadrunner.hdmap.BarrierType]
                  Barriers: [0×1 roadrunner.hdmap.Barrier]
                 SignTypes: [0×1 roadrunner.hdmap.SignType]
                     Signs: [0×1 roadrunner.hdmap.Sign]

    Specify the name of the binary file you want to write the map to. Use the write function to write the map data to the file specified by the argument filename.

    filename = "MyMap.rrhd";

    Input Arguments

    collapse all

    RoadRunner HD Map road data model, specified as a roadrunnerHDMap object. rrMap defines a simple data structure to represent road layouts using lanes, lane boundaries, lane markings, and junctions. This object provides functions that support reading, writing, and plotting HD map data.

    File name to write the map data to, specified as a character vector or string scalar. This argument specifies the absolute or relative path to the binary file you want to write the data to. If you specify a relative path, then the path is relative to the Scenes folder of the current project. filename must end with .rrhd.

    Example: write(rrMap,"MyMap.rrhd") writes the map data to the MyMap.rrhd binary file.

    Data Types: char | string

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.


    WKT projection string, specified as a character vector or string scalar.

    A PROJ.4 projection string, specified as a character vector or string scalar.

    Version History

    Introduced in R2022b

    See Also