2

I am using the osmdata package to bring the universities of Bogota, some of these are mapped as multipolygons. However the plot comes out empty. Any idea how to fix it?

library(osmdata)
library(mapview)
query <- opq(bbox = "Bogota") %>% add_osm_feature(key = "amenity",value = "university") %>% osmdata_sf()
mapview(query$osm_multipolygons[,c("osm_id","name","amenity")], map.types = "OpenStreetMap")
#mapview(query$osm_polygons[,c("osm_id","name","amenity")], map.types = "OpenStreetMap")

Note: when plotting the points or polygons it works correctly.

Rafael Díaz
  • 2,134
  • 2
  • 16
  • 32

1 Answers1

2

The solution is to make a transformation to the object's coordinate system. As it's shown in the following:

library(osmdata)
library(mapview)
library(sf)
query <- opq(bbox = "Bogota") %>% 
  add_osm_feature(key = "amenity",value = "university") %>%
  osmdata_sf()

query <- query$osm_multipolygons[,c("osm_id","name","amenity")] %>%
  st_transform(st_crs("+proj=utm +ellps=GRS80 +datum=WGS84")) %>% 
  st_make_valid() 

mapview(query, map.types = "OpenStreetMap")

enter image description here

For more information check the following link. Coordinate Systems in R

Rafael Díaz
  • 2,134
  • 2
  • 16
  • 32