fix_ggmap_bbox: Fix ggmap bounding box

View source: R/mapping.r

fix_ggmap_bboxR Documentation

Fix ggmap bounding box

Description

The function is part of a process to fix an issue in ggplot2 where vector sf layers and raster ggmap layers do not align properly. It renames the bounding box element to the names st_bbox expects, converts the bbox to an sf polygon, transforms it to EPSG:3875, and then converts back to a bbox.

Usage

fix_ggmap_bbox(.map)

Arguments

.map

(ggmap) A ggmap object as returned by get_stamenmap or similar

Value

returns the original ggmap object but with a respecified bounding box using EPSG:3857 (WGS84)

Examples

## Not run: 
actmap <- get_stamenmap(act_bbox, maptype = "toner-lite", zoom = 13)
actmap <- fix_ggmap_bbox(actmap)
map_data <- st_transform(map_data, crs = 3857)
map_data <- mutate(map_data, geometry = st_transform(geometry, crs = 3857))()

## End(Not run)


baslat/sak documentation built on April 14, 2025, 4:14 p.m.