When plotting road data downloaded from osm using osmdata
, the resulting plot has gaps in it when using larger values of size
in geom_sf
(see image).
Here is a reproducible example using a section of road in SW London. How can I remove the white gaps in the line when plotting?
library(tidyverse)
library(sf)
library(osmdata)
# define bounding box for osm data
my_bbox <-
matrix(c(-0.2605616, -0.2605616,
-0.2004485, -0.2004485,
-0.2605616, 51.4689943,
51.4288980, 51.4288980,
51.4689943, 51.4689943),
ncol = 2)
bbox_sf <- st_geometry(st_polygon(x = list(my_bbox)))
st_crs(bbox_sf) <- 4326
#get osm road data for bounding box
osm_roads_secondary_sf <-
opq(bbox = st_bbox(bbox_sf)) %>%
add_osm_feature(key = 'highway', value = 'secondary') %>%
osmdata_sf()
ggplot() +
geom_sf(data=osm_roads_secondary_sf$osm_lines,size=4)
session info:
R version 3.5.0 (2018-04-23)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6
other attached packages:
[1] osmdata_0.0.7 sf_0.6-3 forcats_0.3.0
stringr_1.3.1
[5] dplyr_0.7.5 purrr_0.2.5 readr_1.1.1
tidyr_0.8.1
[9] tibble_1.4.2 ggplot2_3.0.0 tidyverse_1.2.1.9000