Converting Lat/Lon to map coordinates for mapinterp

4 views (last 30 days)
I have a georeferenced DEM raster with lat, lon, and depth (z) information saved as ascii format. I would like to plot transect lines across the raster and then plot the change in elevation from each raster as a digital relief profile. When I use the function mapinterp, I recieve an error asking me to first convert the lat/lon to map coordinates in Matlab and I have tried to use geodetic2ecef function but also received an error as not enough input arguments.
% [Z, R] = readgeoraster("cheeca_dem_transect_2012.asc",'CoordinateSystemType','geographic',...
% "OutputType","double");
% test out creating transect line on raster
% set latitude (x) and longitude (y) coordinates for transect lines
xp1=[24.89734,24.8975, 24.8976]; % lat coordinates // 1deg increments along the x-axis
yp=(-80.6159:0.00001:-80.61578)';
% Convert latitude and longitude to ECEF coordinates
[x_ecef, y_ecef, z_ecef] = geodetic2ecef(xp1, yp, zeros(size(xp1)));
Error using geodetic2ecef
Not enough input arguments.
% Can not get the code to do these last lines
%https://www.mathworks.com/help/map/ref/geodetic2ecef.html
% Convert ECEF coordinates back to map coordinates
[x_map, y_map] = ecef2geodetic(x_ecef, y_ecef, z_ecef);
% extract W-E profile lines
yp1=yp(1)*ones(size(xp1)); % ycoordinates of the points you want to get.
dist1 = [0, cumsum(sqrt(diff(xp1).^2+diff(yp1).^2))];
zp1 = mapinterp(Z2,R2,xp1,yp1);

Answers (1)

Cris LaPierre
Cris LaPierre on 24 Jan 2024
You need to specify a reference speroid first.

Community Treasure Hunt

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

Start Hunting!