Main Content

getMapROI

Geographic bounding box coordinates from GPS data

Since R2022b

Description

mapParameters = getMapROI(lat,lon) computes the geographic bounding box coordinates using latitude and longitude GPS data, and returns the map parameters mapParameters.

example

mapParameters = getMapROI(lat,lon,Extent=extent) computes the map parameters with the specified GPS buffer extent.

Note

This function requires the Scenario Builder for Automated Driving Toolbox™ support package. You can install the Scenario Builder for Automated Driving Toolbox support package from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

example

Examples

collapse all

Extract map ROI parameters from GPS data. Use the extracted osmUrl parameter to import roads from the OpenStreetMap® web service into a driving scenario. Then, plot the scenario.

Load GPS data containing latitude and longitude values into the workspace.

load("GPSData.mat")

Use the latitude and longitude to fetch the map parameters.

mapParameters = getMapROI(gps.lat,gps.lon);

Use the osmUrl parameter in the mapParameters output structure to import and save the OpenStreetMap file.

fileName = websave("drive_map.osm",mapParameters.osmUrl, ...
    weboptions(ContentType="xml"));

Import the roads from the OpenStreetMap road network file into a driving scenario.

scenario = drivingScenario;
roadNetwork(scenario,"OpenStreetMap",fileName)

Plot the scenario.

plot(scenario)

Extract map ROI parameters from GPS data by specifying GPS buffer extent. Use the extracted osmUrl parameter to import roads from the OpenStreetMap® web service into a driving scenario. Then, plot the scenario.

Load GPS data containing latitude and longitude values into the workspace.

load("GPSData.mat")

Specify the GPS buffer extent, in meters.

gpsBufferExtent = 10;

Use the latitude, longitude, and GPS buffer extent to fetch the map parameters.

mapParameters = getMapROI(gps.lat,gps.lon,Extent=gpsBufferExtent);

Use the osmUrl parameter in the mapParameters output structure to import and save the OpenStreetMap file.

fileName = websave("drive_map.osm",mapParameters.osmUrl, ...
    weboptions(ContentType="xml"));

Import the roads from the OpenStreetMap road network file into a driving scenario.

scenario = drivingScenario;
roadNetwork(scenario,"OpenStreetMap",fileName)

Plot the scenario.

plot(scenario)

Input Arguments

collapse all

Latitude coordinates in degrees, specified as a numeric vector. Each value in the vector must be in the range [–90, 90]. lat must be the same size as lon.

Data Types: single | double

Longitude coordinates in degrees, specified as a numeric vector. Each value in the vector must be in the range [–180, 180]. lon must be the same size as lat.

Data Types: single | double

GPS buffer extent, in meters, specified as a nonnegative scalar. This function extends the rectangular GPS bounding box in all directions by the specified extent value.

Data Types: single | double

Output Arguments

collapse all

Map region of interest (ROI) parameters, returned as a structure.

The structure contains these fields:

PropertyDescription
bufferInMetersGPS buffer extent, returned as a nonnegative scalar. Units are in meters.
minLatMinimum latitude, returned as a scalar. Units are in degrees.
maxLatMaximum latitude, returned as a scalar. Units are in degrees.
minLonMinimum longitude, returned as a scalar. Units are in degrees.
maxLonMaximum longitude, returned as a scalar. Units are in degrees.
georeference

Reference GPS location, returned as a 3-element row vector of the form [latitude longitude altitude]. latitude and longitude values are in degrees, and longitude value is in meters.

The function returns the georeference values latitude and longitude as the center of the bounding box specified by the input lat, lon, and extent values. The value of altitude is 0.

osmUrl

OpenStreetMap® URL, returned as a character vector.

minLatitudeStringMinimum latitude, returned as a character vector. Units are in degrees.
minLongitudeStringMinimum longitude, returned as a character vector. Units are in degrees.
maxLatitudeStringMaximum latitude, returned as a character vector. Units are in degrees.
maxLongitudeStringMaximum longitude, returned as a character vector. Units are in degrees.

The function computes the geographic bounding box coordinates using latitude and longitude GPS data and the specified extent value. The center of the bounding box is the geographical reference point specified by the values of the georeference property. The minimum and maximum latitude and longitude values in the structure represent a rectangular bounding box. This diagram displays the relationship between these coordinates.

Rectangular bounding box with minLat, maxLat, minLon, maxLon, and Extent labeled. The coordinates of the four corners of the bounding box, clockwise from the top-left, are (minLon–Extent, maxLat+Extent), (maxLon+Extent, maxLat+Extent), (maxLon+Extent, minLat–Extent), and (minLon–Extent, minLat–Extent).

Version History

Introduced in R2022b

expand all