Borrar filtros
Borrar filtros

How to assign a depth value to a .tif file

4 visualizaciones (últimos 30 días)
Bradley
Bradley el 12 de Mzo. de 2024
Editada: Karanjot el 23 de Mzo. de 2024
This site has helped me a lot recently and ive learned a ton so thank you again. This time I'm working with a colleague, they have a very complex MATLAB code that plots a very deep fault in the ocean (Rose canyon fault). I dont have access to that code, but its several thousands of lines long and uses alot of complex geometery to plot the fault, however they have never used matlab and are just using the code given to them. What they have asked from me is to find a way to also show the bathymetry of the area over laid on top in 3D space. This is something ive never done but want to figure out. So far I have been able to easily veiw this the tif file in 2D, that was difficult but I cant figure out how to assign a depth value to the surface.
Im using readgeoraster but the documentation online doesnt explain how to assign a depth value. It should be possible in my mind because demcmap correctly colors the tif according to depth. Normally I would use a different program to visualize this in 3D and wouldnt have any problems, its the fault they need however so Im not sure how to continue. Any help is appreciated, thank you again!
[A,R] =readgeoraster('BathyRaster.tif');
latlim = R.LatitudeLimits;
lonlim = R.LongitudeLimits;
usamap(latlim, lonlim)
geoshow(A,R, "DisplayType","Surface")
demcmap(A)
% view(35,60)
I tried attaching the tif file to this post but the website says its an unsupported file type. Its a DEM global mosaic from NCEI Bathymetric Data Viewer with a southwest corner of (-118.91645, 32.59697) and a Northwest corner of (-117.07624, 33.79665). Thanks again!
Heres an example of my current output:

Respuestas (1)

Karanjot
Karanjot el 23 de Mzo. de 2024
Editada: Karanjot el 23 de Mzo. de 2024
Hi Bradley,
To visualize the bathymetry in 3D space, you can use the surf function in MATLAB.
The code below reads the bathymetry data from the TIF file using readgeoraster, creates a grid of latitude and longitude values using meshgrid, and then uses surf to plot the bathymetry as a surface. The daspect function is used to set the correct aspect ratio for latitude and longitude data. Finally, the plot is rotated using view for better visualization. Here's an example of how you can achieve this:
[A, R] = readgeoraster('BathyRaster.tif');
latlim = R.LatitudeLimits;
lonlim = R.LongitudeLimits;
% Create a grid of latitude and longitude values
[lon, lat] = meshgrid(lonlim(1):R.CellExtentInLongitude:lonlim(2), latlim(1):R.CellExtentInLatitude:latlim(2));
% Create a surface plot of the bathymetry
figure
surf(lon, lat, A, 'EdgeColor', 'none')
demcmap(A)
% Set the correct aspect ratio for lat-lon data
daspect([1/cosd(mean(lat(:))), 1, 1])
% Add labels and title
xlabel('Longitude')
ylabel('Latitude')
zlabel('Depth')
title('Bathymetry')
% Rotate the plot for better visualization
view(35, 60)
Please note that the code assumes that the bathymetry data is in meters. If the data is in a different unit, you may need to adjust the plot accordingly.

Categorías

Más información sobre Geology en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by