Plot 2 parallel lines (at given inter-line spacing) and at a given azimuth using mapping tool box functions. The plot does not look reasonable.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tring to plot 2 (or more) parallel lines of fixed length . The start coordinates of the first line are known. The end coordinaes are calculated using the "reckon" function. The spacing between the lines is known. The lines are plotted in the figure but dont appear to be reasonable.The lines should be parallel. cant figure out the error in the code.
% Starting X & Y coordinate
x1=688618.140;
y1=3050595.5945;
llen=4000;%% Line Length in meters
% Determine Lat,Lon values
crs=projcrs(26714); %determine crs using the known EPSG number
[lat1,lon1] = projinv(crs,x1,y1);%Mapping Toolbox function
nm=km2nm(llen/1000);% convert line length in meters to nautical miles
arclen=nm2deg(nm);
az=45;
% determine end points of the line in lat and lon
[lat2,lon2] = reckon(lat1,lon1,arclen,az);
%convert end points to UTM using Mapping Toolbox function
[x2,y2]=projfwd(crs,lat2,lon2); % end coordinates of the line
%--------------------------------------------------
nln=2; % no of parallel lines
LineStartCoordXY=zeros(nln,2); % define matrix of Start coordinates X & Y for the lines
LineStartCoordXY(1,1)=x1;
LineStartCoordXY(1,2)=y1;
%-----------------------------------------------------
% define matrix of End coordinates X & Y for the lines
LineEndCoordXY=zeros(nln,2);
LineEndCoordXY(1,1)=x2;
LineEndCoordXY(1,2)=y2;
sep=100; %separation between the lines
dx=sep*cos(az); % step dx for start coordinates from line 1.
dy=sep*sin(az); % % step dy for start coordinates from line 1.
%---------------------------------------------------------
%compute start coordinates for line 2
for i=2:nln
LineStartCoordXY(i,1)=LineStartCoordXY(i-1,1)+dx;
LineStartCoordXY(i,2)=LineStartCoordXY(i-1,2)+dy;
end
%covert X & Y to lat, lon so that reckon function can be used for computing end
%coordinates for line 2
[line2lat1,line2lon1] = projinv(crs,LineStartCoordXY(2,1),LineStartCoordXY(2,2));
x3=LineStartCoordXY(2,1);
y3=LineStartCoordXY(2,2);
% calculate end points for line 2
[line2lat2,line2lon2] = reckon(line2lat1,line2lon1,arclen,az);
%convert end points to UTM using Mapping Toolbox function
[x4,y4]=projfwd(crs,line2lat2,line2lon2);
LineEndCoordXY(2,1)=x4;
LineEndCoordXY(2,2)=y4;
% Create matrix to draw survey lines in matlab
LineX=[LineStartCoordXY(:,1) LineEndCoordXY(:,1)];
LineY=[LineStartCoordXY(:,2) LineEndCoordXY(:,2)];
figure;
hold on;
pl=line(LineX,LineY);
1 Kommentar
VBBV
am 1 Sep. 2024
@PADMAKAR The coordinates you try to plot as lines are of small length separated by large distance. You can use magnifiers factors to make it appear large and visible in line plot
Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!