[R] 3D Surface plot
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Wed Dec 18 16:42:12 CET 2013
On Wed, Dec 18, 2013 at 2:52 PM, Simon Delay-Fortier
<simon.delay-fortier at mail.mcgill.ca> wrote:
> Hi everyone,
>
> I am a very new user of r (doing most of my previous stuff in vba). I am now mandated to draw a 3-d surface of a mine pit hole. I have all the location points (around 5000 points) of the pit in a CSV file under 3 column X, Y & Z. However, going from page to page on the web, I could not figure out how to code the figure. Something I noted is that most of the time X and Y have to be in ascending order but the data I have are not (since they are finite points of the pit, if X gets in ascending order, Y and Z are not). Also with the data, sometimes 2 rows fallowing each ohter have the same X and Y value with a different Z. That would be nice if things could be modeled with rgl function in order to have a rotating pit, but I would be glad to only have a 3d surface to start!
How "3d" is your surface here? Because there's "3d" and there's
what's known as "2.5d"
A 3d surface could be something like the surface of a sphere, or a
cave, or an overhanging cliff, whereas a 2.5d surface is a
single-valued function of x and y.
If you have a true 3d surface then that's beyond me and involves
working out surface normals and all sorts of other clever stuff which
I don't know about.
If its really 2.5d then yes, you do need to compute the values of
your surface on a grid in order to display it using rgl's surface3d
function. You can do this with some 2d interpolation code, such as
kriging or inverse distance weighting, using assorted packages such as
automap (which makes it easy but beware) or gstat.
Since this seems to be a real-world geography problem, you might haul
over to the r-sig-geo mailing list and as there where the spatial guys
hang out.
Barry
More information about the R-help
mailing list