2

我正在使用该osmdata软件包将波哥大的大学带入其中,其中一些映射为multipolygons. 然而,情节出来是空的。知道如何解决吗?

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")

注意:绘制点或多边形时,它可以正常工作。

4

1 回答 1

1

解决方案是对对象的坐标系进行转换。如下图所示:

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")

在此处输入图像描述

有关更多信息,请查看以下链接。R中的坐标系

于 2020-09-11T17:08:00.187 回答