0

with reprex::reprex() it works perfect (see below), but in Rterm and RStudio console I get errors ... do you have an idea how to solve this? There are some similar questions but I've found no solution so far

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

Thank you very much, Christof

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

Created on 2021-10-22 by the reprex package (v2.0.1)

ckluss
  • 1,477
  • 4
  • 21
  • 33
  • Did you install `GDAL` manually or with a package manager? Which OS are you using? – Gorka Oct 25 '21 at 11:01
  • @Gorka thank you, I've corrected it to reprex::reprex(), I use Windows 11, but the error occured although on Windows 10. GDAL is also installed via Miniconda3, but sf reports GDAL 3.2.1 and gdalinfo.exe GDAL 3.2.2, so the Miniconda3 version does not seem to be the one that is used. – ckluss Oct 25 '21 at 12:57
  • This recent issue [Running GDAL through Python >= 3.8 on Anaconda - DLL load failed](https://github.com/conda-forge/gdal-feedstock/issues/541) seems related with your problem. Do you have ESA SNAP toolbox installed in your system? – Gorka Oct 25 '21 at 13:33
  • @Gorka, thx, no, ESA SNAP toolbox is not installed on my system (and there is no openjp2.dll in system32) – ckluss Oct 26 '21 at 09:05
  • 1
    reinstallation of rdgal with ```install.packages("rgdal", repos="http://R-Forge.R-project.org")``` and setting ```rgdal::set_proj_search_paths("C:/Users/Christof/Documents/R/win-library/4.1/rgdal/proj")``` as described here https://github.com/jhollist/elevatr/issues/48#issuecomment-1059802332 had fixed the problem – ckluss Mar 18 '22 at 17:30

0 Answers0