hypertidy/anglr

Error in mutate_impl(.data, dots)

Closed this issue · 8 comments

Hi Mike,

the code:

data(wrld_simpl)
anglr(subset(wrld_simpl)

produces the error:
Error in mutate_impl(.data, dots) :
Evaluation error: This function should not be called directly.

I'm using only anglr_0.4.6 and sp_1.2-7.

Thanks! I'm just about to push a big fix, lots of implications but a much needed update. Things will be a bit unstable, so bear with me. There's a required update to silicate, but the devtools install process should sort that out.

This globe is with an extreme exaggeration, but should show the idea. There's a simplified Etopo raster in this package, I triangulate wrld_simpl to triangles no larger than 1 square degree, and use an exaggeration on the Etopo metres values to make them visible at world scale. Juggling units here is confusing, and you would make very different choices with a projected map - in time I hope to make it simpler!

data("wrld_simpl", package = "maptools")  ## or library(maptools); data(wrld_simpl)
## grid is long-lat-z (deg-deg-metres)
topo <- raster::raster(system.file("extdata", "gebco1.tif", package = "anglr"))
## model is in native longlat (same as wrld_simpl)
## max_area applies to long-lat, smaller number = smaller triangles
## z is the raster Z values, so we exaggerate them (z will be added to the radius)
model <- anglr(wrld_simpl, z = topo * 1e4,  max_area = 1)

## if we didnt' use globe() we would choose a different exaggeration, maybe topo * 0.01
## because metres vs degrees
mesh <- globe(model)
##rgl::rgl.clear()  ## rgl will default to adding to an existing scene
plot(mesh)
rgl::rglwidget()   ## I need this in RStudio server, Markdown etc. 
 

This should be good now, but things will be a bit unstable for a while, lots of changes coming in silicate and there'll be some back and forth adjustment. I appreciate the feedback!

It works... thank you very much! I've got this warning:

model <- anglr(wrld_simpl, z = topo * 1e4, max_area = 1)
Warning message:
In anglr.PATH(PATH(x), z = z, ..., type = type, max_area = max_area) :

Great, thanks - I'll get to that! Let me know how you go I'm very happy to help you build the scenes you want, and understand the model. It's going to improve a lot soon ...

Mike, may I ask you a few more questions?

  1. How can I get (longitude, latitude, altitude) coordinates instead of (x, y, z) coordinates in meters?
  2. How can I present a cloud of a certain volume (mesh3d) over the France for example, which base is at a height of about 1000 m above the ground level with the globe already plotted?
  3. How can I present a 3D surface over Europe, for example, with the globe already plotted?

Thank you in advance!

I hope it's not too much...

It's not too much! I meant to get back to you, I've changed a lot of things, the main one being you should no longer use the anglr function, plot() now makes a 2D plot, and you need plot3d() to get a 3D plot. Finally, copy_down is used to put a z coordinate on a model that doesn't have one.

  1. If you give it long-lat and altitude you'll get that, it's only globe() that transforms to geocentric XYZ.
## devtools::install_github("hypertidy/silicate")
## devtools::install_github("hypertidy/anglr")

library(silicate)
library(anglr)
data("wrld_simpl", package = "maptools")
france <- DEL(subset(wrld_simpl, NAME == "France"), max_area = 0.01)

plot3d(france)  ## that is longitude-latitude (at altitude =  0)

france_z <- copy_down(france, gebco1) 
plot3d(france_z)  ## that is longitude-latitude (at altitude =  gebco raster height)
rgl::aspect3d(1, 1, 0.1)  ## you might need this, since long-lat-metres are very different scales

You can alternatively set this surface at a different height and add it.

So

plot3d(france_z)  ## that is longitude-latitude (at altitude =  gebco raster height)
rgl::aspect3d(1, 1, 0.1)  ## you might need this, since long-lat-metres are very different scales

france_high <- copy_down(france, z = 10000)
france_high$object$color_ <- "dodgerblue"  ## no nice way yet
plot3d(france_high, add = TRUE)

Any of these can occur the same but wrapped in globe() instead, but I'd recommend figuring out the basics without that first.

Do you have any example specification of a cloud (height, extent etc) or example data set you'd like to plot?