json_to_sf | R Documentation |
This function processes a JSON response body from the Azure Maps API,
extracts the route information, and converts it into a spatial (sf
) object.
json_to_sf(body, main_route = TRUE, linestring = TRUE)
body |
A list, typically the parsed JSON response from an httr2 request. |
main_route |
A logical value. If |
linestring |
A logical value. If |
An sf
object containing the spatial features from the route response,
or NULL
if no valid features are found.
## Not run:
# Assuming 'resp' is an httr2 response object from req_route_directions
body <- httr2::resp_body_json(resp)
route_sf <- json_to_sf(body)
plot(sf::st_geometry(route_sf))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.