I would like to use the sf
package to extract a bounding box (eg, st_bbox
) and pass these coords to a leaflet using fitBounds
.
What is the best way to do this? There is a similar post is here : I don't want to take an average of all coordinates since we already have a bounding box that could be used AND we don't want to have to set the zoom using setView
. An example of what I'm currently trying -
Taking the great state of Indiana:
require(USAboundaries);require(sf)
state <- us_boundaries(states="Indiana")
st_bbox(state)
xmin ymin xmax ymax
-88.11186 37.78194 -84.78395 41.75956
I'd like to get that easily into a format that Leaflet's fitBounds
can interpret. Something like this perhaps?:
map.fitBounds([
[-88.11186, 37.78194],
[-84.78395, 41.75956]
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.