Hello, Could someone suggest a package/way to make a 3D raster plot of the Earth (with continent boundaries), and then make a "cut" or "slice" of it such that one can also visualize some scalar quantity as a function of the Radius/Depth across that given slice ? Formally, I would have a given, fixed longitude, and a list of vectors {latitude, radius, Value} that would show the distribution of the quantity "Value" at various depths and latitudes in 3D. Thanks a lot in advance, Balint [[alternative HTML version deleted]]
1. Have you looked here: https://cran.r-project.org/web/views/Spatial.html (I assume you have done some web searches on possible terms like "3D Earth Data R" or whatever) 2. You might try posting on the r-sig-geo list rather than here, where relative expertise may more likely be available. Cheers, Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Oct 22, 2020 at 11:41 AM Balint Radics <balintradics at gmail.com> wrote:> Hello, > > Could someone suggest a package/way to make a 3D raster plot of the Earth > (with continent boundaries), and then make a "cut" or "slice" of it such > that one can also visualize some scalar quantity as a function of the > Radius/Depth across that given slice ? > > Formally, I would have a given, fixed longitude, and a list of vectors > {latitude, radius, Value} > that would show the distribution of the quantity "Value" at various depths > and latitudes in 3D. > > Thanks a lot in advance, > Balint > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
On 21/10/2020 8:45 a.m., Balint Radics wrote:> Hello, > > Could someone suggest a package/way to make a 3D raster plot of the Earth > (with continent boundaries), and then make a "cut" or "slice" of it such > that one can also visualize some scalar quantity as a function of the > Radius/Depth across that given slice ? > > Formally, I would have a given, fixed longitude, and a list of vectors > {latitude, radius, Value} > that would show the distribution of the quantity "Value" at various depths > and latitudes in 3D.The rgl package has a full sphere of the Earth with (obsolete) political boundaries in example(persp3d). To cut it in half along the plane through a given longitude (and that longitude + 180 deg), you could use clipPlanes3d, or clipObj3d. For example, library(rgl) lat <- matrix(seq(90, -90, len = 50)*pi/180, 50, 50, byrow = TRUE) long <- matrix(seq(-180, 180, len = 50)*pi/180, 50, 50) r <- 6378.1 # radius of Earth in km x <- r*cos(lat)*cos(long) y <- r*cos(lat)*sin(long) z <- r*sin(lat) open3d() ids <- persp3d(x, y, z, col = "white", texture = system.file("textures/worldsmall.png", package = "rgl"), specular = "black", axes = FALSE, box = FALSE, xlab = "", ylab = "", zlab = "", normal_x = x, normal_y = y, normal_z = z) clipFn <- function(coords) { pmax(coords[,1], coords[,2]) # Just an example... } clipObj3d(ids["surface"], clipFn) Filling in the exposed surface could be done with polygon3d(), with some work to construct the polygon. Displaying the function across that surface could be done in a couple of ways, either by using a texture map (like for the map), or subdividing the polygon and setting colour by the coordinates of each vertex. Note that the clipObj3d function isn't on CRAN yet; there you'd have to use clipPlanes3d. You can get the newer version from R-forge. Duncan Murdoch
If you have "value" as a function of latitude and radius, isn't that a 2D (not 3D) scalar field? Which can be plotted using a regular heatmap. If you want a curved edge where depth=0 (radius=?), that's not too difficult to achieve. Not quite sure what continent boundaries mean in this context, but that could possibly be added to. Or do you want a 2D slice superimposed within a 3D space? And if so, does it need to be dynamic? (i.e. Rotate the whole thing, with a trackball/mouse). Note that the further you go down the list above, the more work is required. On Fri, Oct 23, 2020 at 7:41 AM Balint Radics <balintradics at gmail.com> wrote:> > Hello, > > Could someone suggest a package/way to make a 3D raster plot of the Earth > (with continent boundaries), and then make a "cut" or "slice" of it such > that one can also visualize some scalar quantity as a function of the > Radius/Depth across that given slice ? > > Formally, I would have a given, fixed longitude, and a list of vectors > {latitude, radius, Value} > that would show the distribution of the quantity "Value" at various depths > and latitudes in 3D. > > Thanks a lot in advance, > Balint > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Hi Thanks a lot for this pointer, I will need to look at it. I did indeed google but did not find an example. In the meantime some additional solutions were suggested, that I also need to try. Cheers, Balint On Thu 22. Oct 2020 at 20:56, Bert Gunter <bgunter.4567 at gmail.com> wrote:> 1. Have you looked here: > https://cran.r-project.org/web/views/Spatial.html > (I assume you have done some web searches on possible terms like "3D Earth > Data R" or whatever) > > 2. You might try posting on the r-sig-geo list rather than here, where > relative expertise may more likely be available. > > Cheers, > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Thu, Oct 22, 2020 at 11:41 AM Balint Radics <balintradics at gmail.com> > wrote: > >> Hello, >> >> Could someone suggest a package/way to make a 3D raster plot of the Earth >> (with continent boundaries), and then make a "cut" or "slice" of it such >> that one can also visualize some scalar quantity as a function of the >> Radius/Depth across that given slice ? >> >> Formally, I would have a given, fixed longitude, and a list of vectors >> {latitude, radius, Value} >> that would show the distribution of the quantity "Value" at various depths >> and latitudes in 3D. >> >> Thanks a lot in advance, >> Balint >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >[[alternative HTML version deleted]]
Hello, this is very close to exactly what I need! I have tried it and it works nicely, I just have to map some values onto to the polygon or 2D plane that cuts into the 3D object. Thanks! Balint On Thu 22. Oct 2020 at 21:28, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:> On 21/10/2020 8:45 a.m., Balint Radics wrote: > > Hello, > > > > Could someone suggest a package/way to make a 3D raster plot of the Earth > > (with continent boundaries), and then make a "cut" or "slice" of it such > > that one can also visualize some scalar quantity as a function of the > > Radius/Depth across that given slice ? > > > > Formally, I would have a given, fixed longitude, and a list of vectors > > {latitude, radius, Value} > > that would show the distribution of the quantity "Value" at various > depths > > and latitudes in 3D. > > The rgl package has a full sphere of the Earth with (obsolete) political > boundaries in example(persp3d). To cut it in half along the plane > through a given longitude (and that longitude + 180 deg), you could use > clipPlanes3d, or clipObj3d. For example, > > library(rgl) > lat <- matrix(seq(90, -90, len = 50)*pi/180, 50, 50, byrow = TRUE) > long <- matrix(seq(-180, 180, len = 50)*pi/180, 50, 50) > > r <- 6378.1 # radius of Earth in km > x <- r*cos(lat)*cos(long) > y <- r*cos(lat)*sin(long) > z <- r*sin(lat) > > open3d() > ids <- persp3d(x, y, z, col = "white", > texture = system.file("textures/worldsmall.png", package = "rgl"), > specular = "black", axes = FALSE, box = FALSE, xlab = "", ylab > = "", zlab = "", > normal_x = x, normal_y = y, normal_z = z) > > clipFn <- function(coords) { > pmax(coords[,1], coords[,2]) # Just an example... > } > clipObj3d(ids["surface"], clipFn) > > > Filling in the exposed surface could be done with polygon3d(), with some > work to construct the polygon. Displaying the function across that > surface could be done in a couple of ways, either by using a texture map > (like for the map), or subdividing the polygon and setting colour by the > coordinates of each vertex. > > Note that the clipObj3d function isn't on CRAN yet; there you'd have to > use clipPlanes3d. You can get the newer version from R-forge. > > Duncan Murdoch >[[alternative HTML version deleted]]
Thanks for your idea. It should be a 2D slice/plane embedded into a 3D space. Could be static, I just need to make a single figure from it for illustration of the Earth together with its interior in 3D. So, the interior would be a slice in 2D along a fixed longitude. And along this 2D slice would be a heatmap. Again, embedded in 3D, since it would be shown as a slice of Earth in 3D. Duncan?s suggestion is almost exactly what I need so I will try that as a start. Like that it is rotateable which is not a must, but it helps to figure out which angle of view is the best, I hope i can save it as a PDF or image. Also, happy to try other solutions as well, if you think I overcomplicate it! Balint On Thu 22. Oct 2020 at 23:54, aBBy Spurdle, ?XY <spurdle.a at gmail.com> wrote:> If you have "value" as a function of latitude and radius, isn't that a > 2D (not 3D) scalar field? > Which can be plotted using a regular heatmap. > > If you want a curved edge where depth=0 (radius=?), that's not too > difficult to achieve. > Not quite sure what continent boundaries mean in this context, but > that could possibly be added to. > > Or do you want a 2D slice superimposed within a 3D space? > > And if so, does it need to be dynamic? > (i.e. Rotate the whole thing, with a trackball/mouse). > > Note that the further you go down the list above, the more work is > required. > > > On Fri, Oct 23, 2020 at 7:41 AM Balint Radics <balintradics at gmail.com> > wrote: > > > > Hello, > > > > Could someone suggest a package/way to make a 3D raster plot of the Earth > > (with continent boundaries), and then make a "cut" or "slice" of it such > > that one can also visualize some scalar quantity as a function of the > > Radius/Depth across that given slice ? > > > > Formally, I would have a given, fixed longitude, and a list of vectors > > {latitude, radius, Value} > > that would show the distribution of the quantity "Value" at various > depths > > and latitudes in 3D. > > > > Thanks a lot in advance, > > Balint > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]