getMapROI
Description
computes the geographic bounding box coordinates using latitude and longitude GPS data, and
returns the map parameters mapParameters
= getMapROI(lat
,lon
)mapParameters
.
computes the map parameters with the specified GPS buffer extent.mapParameters
= getMapROI(lat
,lon
,Extent=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.
Examples
Import OpenStreetMap Road Network Using Map ROI Parameters
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)
Import OpenStreetMap Road Network Using GPS Data and Extent
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
lat
— Latitude coordinates
numeric vector
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
lon
— Longitude coordinates
numeric vector
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
extent
— GPS buffer extent
0
(default) | nonnegative scalar
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
mapParameters
— Map region of interest parameters
structure
Map region of interest (ROI) parameters, returned as a structure.
The structure contains these fields:
Property | Description |
---|---|
bufferInMeters | GPS buffer extent, returned as a nonnegative scalar. Units are in meters. |
minLat | Minimum latitude, returned as a scalar. Units are in degrees. |
maxLat | Maximum latitude, returned as a scalar. Units are in degrees. |
minLon | Minimum longitude, returned as a scalar. Units are in degrees. |
maxLon | Maximum 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 |
osmUrl | OpenStreetMap® URL, returned as a character vector. |
minLatitudeString | Minimum latitude, returned as a character vector. Units are in degrees. |
minLongitudeString | Minimum longitude, returned as a character vector. Units are in degrees. |
maxLatitudeString | Maximum latitude, returned as a character vector. Units are in degrees. |
maxLongitudeString | Maximum 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.
Version History
Introduced in R2022bR2024a_plus: georeference
field now represents center of bounding box
The function now returns the georeference
field 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.
Previously, when you specified the extent
input argument as a
nonzero value, the returned latitude and longitude
values represented the bottom-left corner of the bounding box specified by the input
lat
, lon
, and extent
values, and if you did not specify the extent
input argument, the
function returned the latitude and longitude values as
the first elements of the input lat
and lon
values, respectively.
See Also
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)