I am trying to make a mask for a georaster (netCDN file) using a shp file. This is similar to what is described in this thread (How to limit the raster processing extent using a spatial mask?), but since my georaster is not an image I do not have an R variable, so the solution presented there does not work for me.
I first load my shapefile into MATLAB:
S1 = shaperead('Export_Output_3.shp');
The data has a Lambert Conformal Conical projection and the units is meters.
Then I load the netCDF file and extract the first slice of data. I get a matrixx with one valu for each cell. It also has a Lambert Conformal Conic projection with the same parameter values, but the data is in “degrees north” and “degrees east”.
So how can I put this data together? I tried the utm2deg function for converting the units of the shapefile from meters to degrees, but I do not know the UTM zone, so I got stuck with that.
I think that I first need to have both datasets in the same units and then to convert the shapefile into a matrix with the same resolution as the netCDF. I am unable to perform any of these steps.
Can anyone help?
Related
I am trying to upload an STL file to MATLAB and be able to manipulate it but can't find the best way to do it.
What I am trying to do is import an STL a file of a hand tool and be able to rotate the 3D image by giving it roll, pitch and yaw angles. The whole system will involve a live read out from an IMU which calculates these angles (going to use a 9 axis IMU - 9250 and hope to incorporate space movement into this but that's progress for another day) which will feed into a function which alters the orientation of the model made from the STL to show in real time how the body is moving. Its important to note the body is fixed so no points can move relative to each other (simplifying the problem).
Currently I have not got far but have modeled the STL fixed in space:
model = createpde(3);
importGeometry(model,'Test_model.stl');
pdegplot(model);
This will plot the STL file. The model is made up of a certain number of faces and vertices which can be plotted but I cannot see a way of manipulating these. I figure that there should be some way of converting this to a 3D matrix of points in x,y,z which I can mulitply by a rotation vector to give a new position rotated by the three angles.
Rx = rotx(psi);
Ry = roty(theta);
Rz = rotz(phi);
R = Rx*Ry*Rz;
Then multiply the model by this and update the plot.
I will also need a way of offsetting all points by certain values to be able to change the point of rotation (where the IMU is placed). I figure once I get the coordinates in a matrix then I can offset them all by certain values in each direction x, y and z.
Can anyone help with this, I have been looking for similar projects but I have not been able to find anything with good code explanations as of yet. The way I am proposing is only my idea, if there is an easier method then please say. Thanks!
I do not have comment privileges so this may not seem like a complete answer.
I've done exactly this type of thin in MATLAB for other research but had to write my own data parsers as I do not have any tool boxes, or importGeometry() didn't exist at the time. The STL is structured as a list of triangles each with a normal and three vertices. I'd ask you, after importing STL what is the data format? An array of positions, a struct or object? Also, what s/w was used to make it. The gmsh format is easier to work with as it gives you a reduced list of points and lists of connections between them based on what simplex contains the points.
If the output of importGeometry is a struct with the full data set then you will have repeated data and need to (1) parse the struct, (2) delete duplicates, (3) stack the results in a 3-by-N or N-by-3 matrix, then operate on this result with the rotation matrix and update plots.
You haven't really asked a specific question but I hope that my comments were helpful.
I plot point cloud figure in MATLAB using Kinect-V2 camera. I determined three markers in the MATLAB figure using the Data cursor tool to get the (x,y,z) of these points. Then, I saved these data as a (.mat file). When I open it again, I found that MATLAB saves the data of each marker in structure array.
How can I get again (x,y,z) of these markers from the Structure arrays?
Attached to the question link of the structure arrays that related to each of the markers.
http://www.mediafire.com/file/yxhjjxh0l312iuz/matlab.mat
Don't really wanna download from an external link so I will have to guess how it looks.
Is it setup like this
--> mydata
--> X
value
--> Y
value
--> Z
value
If it is setup in this manner then all you have to do is write a basic code to extract out the values
data = [mydata.X, mydata.Y, mydata.Z];
I need to interpolate scattered data on a model represented by a 3D surface in Matlab. I tried it using "scatteredInterpolant", but the results were quite bad. This function only allows to specify the query points but not the 'ConnectivityList' because internally it performs its own Delaunay triangulation from the specified point set. However, I perfectly know not only the points but also the 'ConnectivityList', so I can create a Matlab 'triangulation representation' using "triangulation".
So my question is the following. Is there any way to give a predefined 'triangulation' to "scatteredInterpolant"? If it is not possible, is there any other Maltab function or class able to perform data interpolation on a previously triangulated 3D surface instead of performing its own triangulation from the query points?
Can anyone tell me how to generate a 3D surface model like CAD in Matlab ?
1.Input: Input is a collection of points with (x,y,z) where surface is present for an object(I'm using this for a 3D scanner where my inputs are (x,y,z) of surface)
2.Points should be displayed as a surface using some smooth interpolation.
3.More like surface generation from data points.
Thanks you.
In order to plot surfaces, you can use patch function. However, you need along with the points the faces information. In patch a surface consists of polygons that is specified using 3 point, which is the face information.
1
Since it seems like you will be inputting discrete points located on the surface of the object, you will first want to create a Nonconvex Polygon based on the data using Matlab's boundary function.
https://www.mathworks.com/help/matlab/ref/boundary.html
You can then use the trimesh function to create the figure
This question shows the input data and what was produced using this method: How do I create a 3D polygon/mesh over data points?
I have the following scanned image of an area which I want to digitize in terms of coordinates and depths, where depths are shown in terms of contour lines. The depths are shown in the above image by the number over the contour line. I would like to divide this image in terms of grids/pixels and get two data - representing it's (x, y) coordinates and depth - for every grid/pixel.
Is there some Matlab function or File Exchange in Matlab that can be used to perform this task than doing manually? I would like to perform this task faster than if it were to be done manually. Thanks!