Open Heed725 opened 2 years ago
Hi, this looks like it's realted to this issue: https://github.com/jhollist/elevatr/issues/48
Can you share what version of elevatr you have installed with:
packageVersion('elevatr')
Also, do you mind sharing:
sessionInfo()
It seems that this is likely due to some outdated packages. If we figure out what it is then I can add it as a minimum dependency on install. Thanks
packageVersion('elevatr')
[1] ‘0.4.1’
sessionInfo()
sessionInfo() R version 4.1.2 (2021-11-01) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 21996)
Matrix products: default
locale:
[1] LC_COLLATE=English_Tanzania.1252 LC_CTYPE=English_Tanzania.1252
[3] LC_MONETARY=English_Tanzania.1252 LC_NUMERIC=C
[5] LC_TIME=English_Tanzania.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached): [1] compiler_4.1.2 tools_4.1.2 tinytex_0.35 xfun_0.28
Can you load rayshader and rayvista before running session info, please?
library(rayshader)
library(rayvista)
sessionInfo()
library(rayshader) library(rayvista) sessionInfo()
R version 4.1.2 (2021-11-01) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 21996)
Matrix products: default
locale:
[1] LC_COLLATE=English_Tanzania.1252 LC_CTYPE=English_Tanzania.1252
[3] LC_MONETARY=English_Tanzania.1252 LC_NUMERIC=C
[5] LC_TIME=English_Tanzania.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] rayvista_0.1.7.4 rayshader_0.26.6
loaded via a namespace (and not attached):
[1] Rcpp_1.0.7 rgl_0.108.3 codetools_0.2-18 prettyunits_1.1.1 digest_0.6.28
[6] foreach_1.5.1 crayon_1.4.2 R6_2.5.1 jsonlite_1.7.2 lifecycle_1.0.1
[11] magrittr_2.0.1 rlang_0.4.12 progress_1.2.2 doParallel_1.0.16 vctrs_0.3.8
[16] ellipsis_0.3.2 iterators_1.0.13 tools_4.1.2 htmlwidgets_1.5.4 tinytex_0.35
[21] hms_1.1.1 fastmap_1.1.0 xfun_0.28 parallel_4.1.2 compiler_4.1.2
[26] pkgconfig_2.0.3 htmltools_0.5.2 knitr_1.36
Thanks! and how about:
packageVersion('sp')
packageVersion('sp')
‘1.4.6’
okay, that is up to date...
can you also let me know the output from the following:
lapply(c('sp','raster','sf', 'rgdal'), FUN = packageVersion)
and what is printed when you load sf with:
library(sf)
library(rgdal)
lapply(c('sp','raster','sf', 'rgdal'), FUN = packageVersion) [[1]] [1] ‘1.4.6’
[[2]] [1] ‘3.5.2’
[[3]] [1] ‘1.0.4’
[[4]] [1] ‘1.5.27’
library(sf) library(rgdal)
library(sf) Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1 library(rgdal) Loading required package: sp Please note that rgdal will be retired by the end of 2023, plan transition to sf/stars/terra functions using GDAL and PROJ at your earliest convenience.
rgdal: version: 1.5-27, (SVN revision 1148) Geospatial Data Abstraction Library extensions to R successfully loaded Loaded GDAL runtime: GDAL 3.2.1, released 2020/12/29 Path to GDAL shared files: C:/Users/Juma Lungo/Documents/R/win-library/4.1/rgdal/gdal GDAL binary built with GEOS: TRUE Loaded PROJ runtime: Rel. 7.2.1, January 1st, 2021, [PJ_VERSION: 721] Path to PROJ shared files: C:/Users/Juma Lungo/Documents/R/win-library/4.1/rgdal/proj PROJ CDN enabled: FALSE Linking to sp version:1.4-5 To mute warnings of possible GDAL/OSR exportToProj4() degradation, use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal. Overwritten PROJ_LIB was C:/Users/Juma Lungo/Documents/R/win-library/4.1/rgdal/proj
Okay, that all looks okay to me (which is weird).
What about:
sp::CRS(SRS_string = "EPSG:4326")
will do some testing on mwindows machine but currently not able to reproduce this...
sp::CRS(SRS_string = "EPSG:4326")
Error in sp::CRS(SRS_string = "EPSG:4326") : NA
OKay so this is the issue and I don't know why it is happening on your system. For me this returns the following:
sp::CRS(SRS_string = "EPSG:4326")
Coordinate Reference System:
Deprecated Proj.4 representation: +proj=longlat +datum=WGS84 +no_defs
WKT2 2019 representation:
GEOGCRS["WGS 84 (with axis order normalized for visualization)",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]],
ID["EPSG",6326]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8901]],
CS[ellipsoidal,2],
AXIS["geodetic longitude (Lon)",east,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433,
ID["EPSG",9122]]],
AXIS["geodetic latitude (Lat)",north,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433,
ID["EPSG",9122]]]]
I'm not sure how to fix this on my end at the moment I'm afraid. It appears to be a problem with underlying spatial libraries. But seeing as your libraries all seem up to date, this is very strange...
I'll keep track of the issues in {elevatr} and update if there is any news.
I'm also working on a different package that will avoid some of these issues but it it still needs work - I can keep you posted on that.
Cheers
One last dash I tried an alternative to encode this wkt <- sf::st_crs(4326)[[2]] sp::CRS(wkt)
CRS arguments: +proj=longlat +datum=WGS84 +no_defs -----Result----------
wkt <- sf::st_crs(4326)[[2]] sp::CRS(wkt) Coordinate Reference System: Deprecated Proj.4 representation: +proj=longlat +datum=WGS84 +no_defs WKT2 2019 representation: GEOGCRS["WGS 84 (with axis order normalized for visualization)", DATUM["World Geodetic System 1984", ELLIPSOID["WGS 84",6378137,298.257223563, LENGTHUNIT["metre",1]]], PRIMEM["Greenwich",0, ANGLEUNIT["degree",0.0174532925199433]], CS[ellipsoidal,2], AXIS["geodetic longitude (Lon)",east, ORDER[1], ANGLEUNIT["degree",0.0174532925199433]], AXIS["geodetic latitude (Lat)",north, ORDER[2], ANGLEUNIT["degree",0.0174532925199433]]]
CRS arguments: +proj=longlat +datum=WGS84 +no_defs Error: unexpected symbol in "CRS arguments"
Can It mean anything
Yes, basically {sf} resolves many of these legacy PROJ issues I think - however {elevatr} is still using {sp}. I think it is due to be updated at some point but not sure when. Unforunately I don't have the time to track down the issues in elevatr but may be worth testing some of the elevatr functions and reporting in the issue that I referenced earlier on.
If you're really keen to get plotting with something you are welcome to try out the dev version of {raytrix} https://github.com/h-a-graham/raytrix
The following should work but I can't guarentee anything as, like I said, this is still a work in progress.
# devtools::install_github('h-a-graham/raytrix')
library(raytrix)
library(rayshader)
.lat <- 57.219566
.long <- -6.092690
# sets extent and projection
set_canvas_centroid(lat=.lat, long=.long, radius = 10000)
# download height data
dem_matrix <- topo_matrix(20, src='aws')
#download rgb overlay
overlay_array <- map_drape(5, src='wms_virtualearth')
# plot in 3d with rayshader
plot_3d(overlay_array, dem_matrix, zscale=20*0.75)
Sorry that we can't find a solution right now - I'll leave this open and hopefully we can fix it in the near future...
The raytrix works I will stick with this for the time being, Thank you, please keep me updated and cheers 👍
Umm Hello I'm using Windows I tried to run The following code example It gave me a Lot of errors
Line of code
library(rayshader) library(rayvista)
.lat <- 57.219566 .long <- -6.092690
cuillins <- plot_3d_vista(lat = .lat, long = .long, phi=30)
render_label(heightmap= cuillins, text='Bla Bheinn: 928 m', lat = .lat, long=.long, extent = attr(cuillins, 'extent'),altitude=600, clear_previous = T, zscale = 2)
render_compass()
render_scalebar(limits=c( round(dim(cuillins)[2]*attr(cuillins, 'resolution')/1000,1)), label_unit = 'km')
render_snapshot(clear=TRUE)
Error given
library(rayshader)
Help Me