首页 > 解决方案 > sp::CRS 和 ggspatial::annotation_map_tile 分别出错

问题描述

它工作得reprex::reprex()很好(见下文),但在 Rterm 和 RStudio 控制台中我得到错误......你知道如何解决这个问题吗?有一些类似的问题,但到目前为止我还没有找到解决方案

rgdal::rgdal_extSoftVersion()
#> Error: no such table: metadata
sp::CRS(SRS_string='EPSG:4326')
#> Error in sp::CRS(SRS_string = "EPSG:4326") : NA
sp::CRS("+init=epsg:4326")
#> Error in sp::CRS("+init=epsg:4326") : NA

ggplot2::ggplot() +
   ggspatial::annotation_map_tile(
     zoom = 13, cachedir = system.file("rosm.cache", package = "ggspatial")) +
   ggplot2::geom_sf(data = longlake_waterdf, fill = NA, col = "grey50")
#> Error in sp::CRS(paste0("+init=epsg:", epsg)) : NA

非常感谢,克里斯托夫

sf::sf_extSoftVersion()
#>           GEOS           GDAL         proj.4 GDAL_with_GEOS     USE_PROJ_H 
#>        "3.9.1"        "3.2.1"        "7.2.1"         "true"         "true" 
#>           PROJ 
#>        "7.2.1"
 
rgdal::rgdal_extSoftVersion()
#>           GDAL GDAL_with_GEOS           PROJ             sp           EPSG 
#>        "3.2.1"         "TRUE"        "7.2.1"        "1.4-5"      "v10.008"

sp::CRS(SRS_string='EPSG:4326')
#> CRS arguments: +proj=longlat +datum=WGS84 +no_defs
sp::CRS("+init=epsg:4326")
#> CRS arguments: +proj=longlat +datum=WGS84 +no_defs
 
wkt <- sf::st_crs(4326)[[2]]
sp::CRS(wkt)
#> CRS arguments: +proj=longlat +datum=WGS84 +no_defs


ggspatial::load_longlake_data()

ggplot2::ggplot() +
  ggspatial::annotation_map_tile(
    zoom = 13, cachedir = system.file("rosm.cache", package = "ggspatial")) +
  ggplot2::geom_sf(data = longlake_waterdf, fill = NA, col = "grey50")
#> Zoom: 13

reprex 包于 2021-10-22 创建(v2.0.1)

标签: rggplot2spreprexggspatial

解决方案


推荐阅读