Closed superboreen closed 3 years ago
Hey, thanks for this. Can you share you sessionInfo()
please? By the looks of things (hopefully) this is due to older versions of some of the spatial dependencies. I may need to specify minimum version numbers for some of these packages.
Thanks
Happy to. See below.
R version 4.0.4 (2021-02-15) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.1 LTS
Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_IE.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_IE.UTF-8 LC_COLLATE=en_IE.UTF-8
[5] LC_MONETARY=en_IE.UTF-8 LC_MESSAGES=en_IE.UTF-8
[7] LC_PAPER=en_IE.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_IE.UTF-8 LC_IDENTIFICATION=C
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] rayvista_0.1.0 rayshader_0.24.10
loaded via a namespace (and not attached):
[1] progress_1.2.2 terra_1.2-10 tidyselect_1.1.1
[4] xfun_0.23 purrr_0.3.4 sf_0.9-8
[7] lattice_0.20-41 colorspace_2.0-1 vctrs_0.3.8
[10] generics_0.1.0 miniUI_0.1.1.1 htmltools_0.5.1.1
[13] utf8_1.2.1 rlang_0.4.11 manipulateWidget_0.10.1
[16] e1071_1.7-6 later_1.2.0 pillar_1.6.1
[19] glue_1.4.2 DBI_1.1.1 slippymath_0.3.1
[22] sp_1.4-5 foreach_1.5.1 lifecycle_1.0.0
[25] munsell_0.5.0 raster_3.4-10 htmlwidgets_1.5.3
[28] codetools_0.2-18 knitr_1.33 fastmap_1.1.0
[31] doParallel_1.0.16 httpuv_1.6.1 crosstalk_1.1.1
[34] curl_4.3.1 parallel_4.0.4 class_7.3-17
[37] fansi_0.4.2 maptiles_0.1.3 Rcpp_1.0.6
[40] KernSmooth_2.23-18 xtable_1.8-4 scales_1.1.1
[43] promises_1.2.0.1 classInt_0.4-3 elevatr_0.3.4
[46] webshot_0.5.2 jsonlite_1.7.2 mime_0.10
[49] png_0.1-7 hms_1.0.0 digest_0.6.27
[52] dplyr_1.0.6 shiny_1.6.0 grid_4.0.4
[55] tools_4.0.4 magrittr_2.0.1 rgl_0.106.8
[58] proxy_0.4-25 tibble_3.1.2 crayon_1.4.1
[61] pkgconfig_2.0.3 ellipsis_0.3.2 prettyunits_1.1.1
[64] assertthat_0.2.1 iterators_1.0.13 R6_2.5.0
[67] units_0.7-1 compiler_4.0.4
Hmmm... Nothing I can see that stands out as being odd... I can't see {rgdal} in this list but I'm not sure this should matter.
Can you try this and let me know if you get the same error please:
library(rayvista) HopkinsNZ <- plot_3d_vista(lat=-44.042238, long=169.860985, radius=5000, overlay_detail = 13, elevation_detail=10, zscale=25, img_provider = 'OpenStreetMap',theta=25, phi=25, zoom=0.5, windowsize =1200, solid=T, background='grey10')
Thanks again!
Sorry for delay in replying. Busy busy. I ran your code above and got this:
Error in if ((is.null(sp::wkt(locations)) | nchar(sp::wkt(locations)) == : argument is of length zero In addition: Warning messages: 1: In sp::wkt(locations) : CRS object has no comment 2: In sp::wkt(locations) : CRS object has no comment 3: In sp::wkt(locations) : CRS object has no comment
No worries! Thanks for getting back to me. Hmmm... the plot thickens..
Can you let me know what is printed when you load {sf} with:
library(sf)
And also, if you don't mind, can you tell me what happens with this? It should print the projection of the polygon...
define_extent <- function(lat, long, radius, epsg){
extent_sf <- sf::st_sfc(sf::st_point(c(long, lat))) %>%
sf::st_set_crs(epsg) %>%
sf::st_transform(3857) %>%
sf::st_buffer(radius)%>%
sf::st_bbox()%>%
sf::st_as_sfc()%>%
sf::st_sf()
return(extent_sf)
}
sf_poly <- define_extent(lat=-44.042238, long=169.860985, radius=5000, epsg=4326)
sp::wkt(sf::as_Spatial(sf_poly))
My feeling is that this could be due to an old version of proj/gdal...
Thanks again.
Hi,
I got the same error at
cuillins <- plot_3d_vista(lat = .lat, long = .long, phi = 30)
although I am using another R version and Platform.
sessionInfo()
R version 4.0.3 (2020-10-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19042) Matrix products: default locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] rayvista_0.1.0 rayshader_0.24.10 loaded via a namespace (and not attached): [1] Rcpp_1.0.5 knitr_1.30 magrittr_2.0.1 hms_1.0.0 progress_1.2.2
[6] doParallel_1.0.16 xtable_1.8-4 R6_2.5.0 rlang_0.4.10 fastmap_1.0.1
[11] foreach_1.5.1 tools_4.0.3 webshot_0.5.2 parallel_4.0.3 xfun_0.20
[16] miniUI_0.1.1.1 htmltools_0.5.1.1 crosstalk_1.1.0.1 iterators_1.0.13 ellipsis_0.3.1
[21] digest_0.6.27 rgl_0.103.5 lifecycle_1.0.0 crayon_1.4.1 shiny_1.5.0
[26] later_1.1.0.1 htmlwidgets_1.5.3 vctrs_0.3.6 promises_1.1.1 codetools_0.2-18
[31] manipulateWidget_0.10.1 mime_0.9 compiler_4.0.3 prettyunits_1.1.1 jsonlite_1.7.2
[36] httpuv_1.5.4 pkgconfig_2.0.3
Using library(sf)
gives the following information and warning:
library(sf) Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1 Warnmeldung: Paket ‘sf’ wurde unter R Version 4.0.5 erstellt
Running
define_extent <- function(lat, long, radius, epsg){ extent_sf <- sf::st_sfc(sf::st_point(c(long, lat))) %>% sf::st_set_crs(epsg) %>% sf::st_transform(3857) %>% sf::st_buffer(radius)%>% sf::st_bbox()%>% sf::st_as_sfc()%>% sf::st_sf() return(extent_sf) } sf_poly <- define_extent(lat=-44.042238, long=169.860985, radius=5000, epsg=4326) sp::wkt(sf::as_Spatial(sf_poly))
will return null with the following warning
NULL Warnmeldung: In sp::wkt(sf::as_Spatial(sf_poly)) : CRS object has no comment
I hope this will help you.
Very helpful - thank you! This at least pin points the problem. I think there are multiple solutions to this problem but I'm not aware of one size fits all solution at the moment - I'll do a bit poking around and see what I come up with. Thansk again!
Any chance you could try updating {rgdal} and try again?
install.packages("rgdal", repos="http://R-Forge.R-project.org")
Based on this blog here: https://r-spatial.org/r/2020/03/17/wkt.html it is a possible solution.
If not there should be a work around that I can add in...
To check if this might work can you let me know what the following returns, please?
sp::wkt(sp::CRS(SRS_string='EPSG:4326'))
I had the same issue, updating rgdal solved it for me.
Obviously was running an old GDAL version. Thanks!
When I run library(sf) I get this:
Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
When I run the other code I get this:
NULL Warning message: In sp::wkt(sf::as_Spatial(sf_poly)) : CRS object has no comment
Okay, that's at least consistent with the others in this thread. Can you try updating rgdal and see if that helps?
I updated rgdal and re-ran your code snippet above, but got the following!
[1] "PROJCRS[\"WGS 84 / Pseudo-Mercator\",\n BASEGEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4326]],\n CONVERSION[\"unnamed\",\n METHOD[\"Popular Visualisation Pseudo Mercator\",\n ID[\"EPSG\",1024]],\n PARAMETER[\"Latitude of natural origin\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8801]],\n PARAMETER[\"Longitude of natural origin\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8802]],\n PARAMETER[\"False easting\",0,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8806]],\n PARAMETER[\"False northing\",0,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8807]]],\n CS[Cartesian,2],\n AXIS[\"(E)\",east,\n ORDER[1],\n LENGTHUNIT[\"metre\",1]],\n AXIS[\"(N)\",north,\n ORDER[2],\n LENGTHUNIT[\"metre\",1]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World - 85°S to 85°N\"],\n BBOX[-85.06,-180,85.06,180]],\n ID[\"EPSG\",3857]]" Warning messages: 1: In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) : Discarded ellps WGS 84 in Proj4 definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs 2: In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) : Discarded datum World Geodetic System 1984 in Proj4 definition 3: In showSRID(SRS_string, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) : Discarded ellps WGS 84 in Proj4 definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs 4: In showSRID(SRS_string, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) : Discarded datum World Geodetic System 1984 in Proj4 definition
That looks promising, any luck with plot_3d_vista, now?
When I run that I get this:
Donloading Overlay...
NULL
Downloading DEMs [===========================] 100% eta: 0s
Mosaicing & Projecting
Clipping DEM to bbox
Filling NA raster values... If this is very slow use `fill_holes=FALSE`
[1] "Dimensions of matrix are: 1618x1536."
There were 43 warnings (use warnings() to see them)
then when I run the render_label command I get this
Error in rgl.texts(x = 0.0165617779828153, y = 743.854095458984, z = 0.542318261008518, :
FreeType not supported in this build
Okay, great, so it looks like the scene is being shown in the rgl window as expected? You can either install freetype (an external program) or add the argument freetype=FALSE. See here for the docs for render_label: https://www.rayshader.com/reference/render_label.html
It sounds like the issue here was an old rgdal version. I'll add this as a dependency before closing this issue. Thanks for your help.
Happy to help. I am not out of the woods yet, though. When I run your last command:
render_snapshot(clear=TRUE)
I get this and the image in the Viewer window is just a black square.
Warning message:
In rgl.snapshot(filename, fmt, top) :
this build of rgl does not support snapshots
Haha! This is a new one for me... Perhaps try updating the rgl package?
Yeah I am stumped but then again I am just a noob at this R & GIS stuff. I did update rgl using your suggested command above but I am not convinced it actually did update or else it was already up to day. I have a sneaking suspicion I probably need to or should update some Ubuntu packages so I might invest some time in that and see if it works. Will let you know if I get it working.
More instructions on installing rgl here: https://dmurdoch.github.io/rgl/dev/ May need to install opengl in addition to reinstalling. Good luck!
Updating {rgdal} solved the problem and plot_3D_vista works as expected. Thank you :)
As you requested:
sp::wkt(sp::CRS(SRS_string='EPSG:4326'))
gives the following output after rgdal-update:
[1] "GEOGCRS[\"WGS 84 (with axis order normalized for visualization)\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]],\n ID[\"EPSG\",6326]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8901]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433,\n ID[\"EPSG\",9122]]],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433,\n ID[\"EPSG\",9122]]]]"
Okay, so I've just made an update which adds a recent version of rgdal as a suggested dependency and added 'dependencies=TRUE' to the README installation instructions. https://github.com/h-a-graham/rayvista/pull/8 This should now automatically install a recent version of rgdal and hopefully avoid these issues. If this continues feel free to reopen. @superboreen if you continue to have issues relating to rayshadder functions following 'plot_3d_vista' feel free to open a discussion here: https://github.com/h-a-graham/rayvista/discussions or it may be appropriate to submit an issue in the rayshader repo. Thanks all for your help with this issue - it's much appreciated!
I had been getting the following error when trying to follow your tutorials:
> library(rayshader)
> library(rayvista)
> cuillins <- plot_3d_vista(lat = .lat, long = .long, phi=30)
Retrieving cached overlay data...
Error: Request failed after 10 attempts
Run `rlang::last_error()` to see where the error occurred.
In addition: There were 30 warnings (use warnings() to see them)
And the same:
> HopkinsNZ <- plot_3d_vista(lat=-44.042238, long=169.860985, radius=5000, overlay_detail = 10, elevation_detail=10, zscale=20, img_provider = 'OpenStreetMap', cache_dir = 'testing',theta=25, phi=25, zoom=0.5, windowsize =1200, solid=T, background='grey10')
Retrieving cached overlay data...
Error: Request failed after 10 attempts
Run `rlang::last_error()` to see where the error occurred.
In addition: There were 30 warnings (use warnings() to see them)
But having gone through your troubleshooting, it was updating rgdal that fixed it.
Thanks!
I get this error when I run your example.
Retrieving cached overlay data... Error in if ((is.null(sp::wkt(locations)) | nchar(sp::wkt(locations)) == : argument is of length zero
I get it immediately after I run this command from your example:
cuillins <- plot_3d_vista(lat = .lat, long = .long, phi = 30)