How find x, y, z position of .grd. file with an initial point and distace?

7 Ansichten (letzte 30 Tage)
Hello!
I have a question about the use of .grd file on MATLAB.
I have a global grid .grd file of the global topo/bathy depths. I have the grdread2 MATLAB pack to read the .grd file. I need to find the specific x,y,z positions from the following conditions:
1-I have the lat and long coordinates of an initial point.
2-I have one back-azimuth direction.
3-I have a total length of 2000 km.
4-I need to extract all seafloor depth km by km along the total length of step 3, starting at the position informed in step 1 and going on the direction of step 2.
5-After extracting all depths, I need to create a variable with the lat and long of the place where the depth is > 7000 m.
Does someone know how I can do that?
I know how to use GMT with the project command on shell language. However, I would like to find some way to do this on MATLAB, which I am using to do other processes to obtain the lat, long, and azimuth.
I will be grateful for any help.
Thanks,
Guilherme
  1 Kommentar
Guilherme de Melo
Guilherme de Melo am 6 Jun. 2023
I found a matlab command to extract automatically the depth of the geographical coordinates provided:
>> getDepth([lat_mean_st123_array transpose(lat_final_line_point_mean)], [long_mean_st123_array transpose(long_final_line_point_mean)])
ans =
-2022
-4370
at_mean_st123_array and transpose(lat_final_line_point_mean) are the initial and final latitude
long_mean_st123_array and transpose(long_final_line_point_mean) are the initial and final longitude
Then, I only need to find a way to identify all lat/long coordinates along the line linking the initial and final lat/long. After that, I can apply all coordinates on the getDepth plugin to obtain all depths. Any suggestion to obtain all coordinates between the two points?
thanks,

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Rohit Kulkarni
Rohit Kulkarni am 14 Aug. 2023
Hi,
You can follow the following steps for finding the coordinates:
  1. Use grdread2 to read .grd file.
  2. Convert the latitude and longitude coordinates of the initial point to the corresponding grid indices using the grdsearch function. This will give you the grid indices (i, j) of the initial point on the grid.
  3. Calculate step size.
  4. Convert the back-azimuth direction to a unit vector representing the direction.
  5. Iterate over the desired number of steps along the path. At each step, calculate the new position by adding the direction vector multiplied by the step size to the previous position.
  6. Check if each extracted depth value is greater than 7000 meters. If it is, store the corresponding latitude and longitude coordinates in a separate variable.
A sample code snippet that demonstrates the above steps:
% Step 1: Read .grd file
[lat, lon, depth] = grdread2('global_grid.grd');
% Step 2: Convert initial point coordinates to grid indices
[i, j] = grdsearch(lon, lat, lon_initial, lat_initial);
% Step 3: Calculate step size
step_size = total_length / num_steps;
% Step 4: Calculate direction vector
direction_vector = [cosd(back_azimuth), sind(back_azimuth)];
% Step 5: Extract depths along the path
depths = [];
positions = [];
for step = 1:num_steps
% Calculate new position
new_position = [lon(i, j), lat(i, j)] + direction_vector * step_size;
% Interpolate depth at new position
new_depth = interp2(lon, lat, depth, new_position(1), new_position(2));
% Store depth and position
depths = [depths; new_depth];
positions = [positions; new_position];
% Update indices for next step
i = new_position(2);
j = new_position(1);
end
% Step 6: Identify depths > 7000 m
high_depth_indices = depths > 7000;
high_depth_positions = positions(high_depth_indices, :);
Thanks

Community Treasure Hunt

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

Start Hunting!

Translated by