如何从HERE REST API获取道路数据及地理坐标等附加信息
Hey there! I see you've been using HERE's Map Tile API but only getting pixel-based street labels, and you're looking to fetch actual geographic coordinates (latitude/longitude) plus additional road data like route numbers. Let's walk through the right tools and steps to get this done.
First, it's important to clarify: the Map Tile API is designed for rendering map tiles, which is why it returns pixel coordinates for labels instead of real geographic data. To get road geometry and attributes, you'll need to use HERE's APIs built specifically for map data extraction.
Here are two primary APIs that will give you the data you need:
1. HERE Roads API
This API is tailored to retrieve detailed road information, including geographic coordinates, road numbers, names, and road types. It's perfect for getting road geometry as a list of latitude/longitude points.
Example Request
GET https://roads.api.here.com/v1/roads?bbox=52.5159,13.3777,52.5179,13.3807&apiKey={YOUR_API_KEY}
- The
bboxparameter defines the area you want to query (format:minLat,minLon,maxLat,maxLon). - Replace
{YOUR_API_KEY}with your valid HERE API key.
Key Response Data
In the response, each road entry will include:
geometry: An array of[latitude, longitude]pairs representing the road's path.attributes: Contains details likeroadNumber(route/road ID),name,roadType, and more.
2. HERE Map Data API
If you need even more granular road data (like lane counts, turn restrictions, or full network topology), the Map Data API is the way to go. It provides structured, feature-rich map data for specific layers (including roads).
Example Request
GET https://mapdata.api.here.com/v1/mapdata?layers=ROAD_GEOM_FC&bbox=52.5159,13.3777,52.5179,13.3807&apiKey={YOUR_API_KEY}
- The
layersparameter specifies which map data layer to retrieve (here,ROAD_GEOM_FCfor road geometry features). - Again, use your API key for authentication.
Key Response Data
The response will include features objects, each with:
geometry: A GeoJSON structure with the road's geographic coordinates.properties: A full set of road attributes, including route numbers, road class, and connectivity info.
- Authentication Update: HERE has phased out
app_idandapp_codein favor of API Keys. Make sure you generate a valid API Key from your HERE Developer account to use these APIs. - Filtering Data: Use parameters like
filterto narrow down results (e.g., only fetch highways or local roads) and avoid unnecessary data. - Rate Limits: Be mindful of the API's rate limits to prevent service interruptions. Check the HERE documentation for specific limits per API.
内容的提问来源于stack exchange,提问作者Alexander Chernetcov

