I have a problem working with plotting a polygon obtained by osmdata. First, I get the polygon of the object using this code
library(osmdata)
loespejo_mersal <- opq_osm_id (type = "way", id = 39259197)%>%
opq_string () %>%
osmdata_sf ()
And i got the data without problem, but when I need to plot in a certain limit, I got the error.
ggplot() +
geom_sf(data = loespejo_mersal$osm_polygons,
inherit.aes = FALSE,
fill = "red",
size = .1,
alpha = .5)+
coord_sf(xlim= c(-70.71, -70.67),
ylim = c(-33.54, -33.50),
expand = FALSE)+
labs(title = "TEST Mersan")
Warning message:
In st_cast.GEOMETRYCOLLECTION(X[[i]], ...) :
only first part of geometrycollection is retained
But if i change the limits, I don't have problems.
ggplot() +
geom_sf(data = loespejo_mersal$osm_polygons,
inherit.aes = FALSE,
fill = "red",
size = .1,
alpha = .5)+
coord_sf(xlim= c(-70.75, -70.65),
ylim = c(-33.6, -33.5),
expand = FALSE)+
labs(title = "TEST Mersan")
I'm trying to understand the error, but I'm stuck :(