如何用SF绘制OSM文件?

时间:2018-11-15 00:28:26

标签: r openstreetmap

我正在尝试使用plot_sf从openstreemap中绘制shapefile,但是却出现了空白。这是我正在尝试的:

library("osmdata")
#> Data (c) OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright
bb <- getbb("Sevilla")
q <- opq(bb)
q <- q %>% add_osm_feature(key = "highway", value = "motorway")
q1 <- opq_string(q)
dt <- osmdata_sf(q1)
sf::plot_sf(dt$osm_lines)

1 个答案:

答案 0 :(得分:1)

这对我有用。与您的几乎相同:

library(osmdata)
library(sf)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright
bb <- getbb("Sevilla")
q <- opq(bb)
q <- q %>% add_osm_feature(key = "highway", value = "motorway")
q1 <- opq_string(q)
dt <- osmdata_sf(q1)
plot(dt)
dt$osm_lines
plot(dt$osm_lines)

enter image description here