I have a data set of XYZ coordinates (lake bathymetry) and I want to create a grid out of them for later meshing purposes using GMSH. I know that there is an easy way to do it in MATLAB using the boundary(x,y,z) function. Unfortunately, I couln't find anything similar in R and I have too many points to create boundary lines by hand.
Does anyone has an idea how to proceed with this in R? At the end I need the lines consisting of the outer points in my point cloud.
Thanks a lot!
You can try using chull which finds the convex hull.
From the chull help
X <- matrix(stats::rnorm(2000), ncol = 2)
chull(X)
plot(X[,1],X[,2])
points(X[chull(X),1],X[chull(X),2],col=2,pch=19)
In my project I am using different projections for my data. I want to learn what happens when you create shapes in a equivalent (equal area) projection and transform them to a conformal projection.
I have a SPDF in an equal area projection. I am trying to create some shapes in this SPDF to later transform them. I did not expect that this is a difficult task. I would like to work with vectors.
The main problem I think I have is that I am unaware of the package and function I should use. I have searched for a couple of hours this morning but can not find the right package or function. Also I can not find people asking questions about this exact topic, which surprises me.
So the question is: How do I make a shape in a SPDF using R?
This might be a stupid question...
I've two vectors containing Y coords
X is simply 1:8
I've added the lines to a plot area and would like to identify the point of intersection of the two lines.
Is there a default package to find this?
Thanks
The intersection of two lines is found analytically by solving the two linear equations which define the lines. I'll leave the math as an exercise to the OP.
If you want to use a very helpful and powerful package, you could read up on the package spatstat . Once you've converted your lines into psp objects, use spatstat:crossing.psp to find intersections.
I've got data representing 3D surfaces (i.e. earthquake fault planes) in xyz point format. I'd like to create a 3D representation of these surfaces. I've had some success using rgl and akima, however it can't really handle geometry that may fold back on itself or have multiple z values at the same x,y point. Alternatively, using geometry (the convhulln function from qhull) I can create convex hulls that show up nicely in rgl but these are closed surfaces where in reality, the objects are open (don't completely enclose the point set). Is there a way to create these surfaces and render them, preferably in rgl?
EDIT
To clarify, the points are in a point cloud that defines the surface. They have varying density of coverage across the surface. However, the main issue is that the surface is one-sided, not closed, and I don't know how to generate a mesh/surface that isn't closed for more complex geometry.
As an example...
require(rgl)
require(akima)
faultdata<-cbind(c(1,1,1,2,2,2),c(1,1,1,2,2,2),c(10,20,-10,10,20,-10))
x <- faultdata[,1]
y <- faultdata[,2]
z <- faultdata[,3]
s <- interp(x,z,y,duplicate="strip")
surface3d(s$x,s$y,s$z,col=a,add=T)
This creates generally what I want. However, for planes that are more complex this doesn't necessarily work. e.g. where the data are:
faultdata<-cbind(c(2,2,2,2,2,2),c(1,1,1,2,2,2),c(10,20,-10,10,20,-10))
I can't use this approach because the points are all vertically co-planar. I also can't use convhulln because of the same issue and in general I don't want a closed hull, I want a surface. I looked at alphashape3d and it looks promising, but I'm not sure how to go about using it for this problem.
How do you determine how the points are connected together as a surface? By distance? That can be one way, and the alphashape3d package might be of use. Otherwise, if you know exactly how they are to be connected, then you can visualize it directly with rgl structures.
I wonder if someone can help me to find the area of a 2-D object in Cartesian plane , when we know coordinates of every points.
Eg : I want to calculate the area of a triangular. A(12,34) B(45,89) C(25,35)
I want a common algorithm to find any 2-D object's area.
Thank you.
Here you go, uses triangulation. This was literally the top result off Google when I searched "area of polygon given set of points". Please do your research before posting.
If your object is a simple polygon, there's no need to triangulate it to compute its area. There's a simple formula that depends only on the coordinates of the vertices. See http://en.wikipedia.org/wiki/Polygon#Area_and_centroid