bufferm works differently with the same data sets?

조회 수: 1 (최근 30일)
Faez Alkadi
Faez Alkadi 2021년 11월 25일
편집: Faez Alkadi 2021년 12월 2일
I am using bufferm to find buffer arounf letters of a name. The letter are consisting of segments in both clockwise and anti_clockwise. first file with name Name works perfect while the other file named Name_Shifted doesn't.
Both files are attached
Note: I have also used bufferm2 but didn't work !!!
Here is what is did for the first file Name:
BufferSize=0.3;
Segments=Name;
%Segments=Name_Shifted;
for L=1:length(Segments(:, 1))
xyz=Segments{L, 1};
xyz1=[xyz;xyz(1,:)]; %To close the segment
xyz2=xyz1;
plot(xyz2(:,1),xyz2(:,2),'color',rand(1,3))
hold on
[x1,y1] = bufferm(xyz1(:,1),xyz1(:,2),BufferSize,'in');
xyz3=[x1,y1];
plot(xyz3(:,1),xyz3(:,2),'Color','k')
hold on
end
and this was the result:
However, Here is what is did for the first file Name_Shifted :
BufferSize=0.3;
%Segments=Name;
Segments=Name_Shifted;
for L=1:length(Segments(:, 1))
xyz=Segments{L, 1};
xyz1=[xyz;xyz(1,:)]; %To close the segment
xyz2=xyz1;
plot(xyz2(:,1),xyz2(:,2),'color',rand(1,3))
hold on
[x1,y1] = bufferm(xyz1(:,1),xyz1(:,2),BufferSize,'in');
xyz3=[x1,y1];
plot(xyz3(:,1),xyz3(:,2),'Color','k')
hold on
end
and this was the result:

채택된 답변

Harikrishnan Balachandran Nair
Harikrishnan Balachandran Nair 2021년 12월 1일
Hi Faiz,
I understand that you are trying to find the buffer zone inside your polygon using the 'bufferm' function. The 'bufferm' function expects the inputs to be in degrees, specifying the latitude and longitude.
However , In the 'Name_Shifted' mat file, i understand that you have shifted all the points in the 'x' and 'y' direction by a value of 200. when these values are given as input to the 'bufferm' function, it is perceived as latitudes and longitudes. This makes the latitude take values which is much more than 90 degree .This is the reason that the results are not as expected.
You can observe the issue by using 'geoplot' instead of 'plot' for plotting these polygons in the geographic co-ordinates.
  댓글 수: 1
Faez Alkadi
Faez Alkadi 2021년 12월 2일
편집: Faez Alkadi 2021년 12월 2일
Hello Harikrishnan,
Thanks for your reply and explination. I solved the problem using polybuffer as you may see in the attached picture.
Thank you again
BufferSize=0.3;
xyzall=[];
NumOfBuf=3; % Number of times to buffer
Segments=Name_Shifted;
for L=1:length(Segments(:, 1))
xyz=Segments{L, 1};
xyzall=[xyzall;xyz;NaN NaN NaN];
end
xyzall=[xyzall;xyzall(1,:)];% closre the polygon
polyline = polyshape({xyzall(:,1)},{xyzall(:,2)}); % Build polyline to shrink it as may times as desired (NumOfBuf)
for i=1:NumOfBuf% For number of segments
% shrink with amount of the BufferSize
polyin = polybuffer(polyline,-(i*BufferSize));
plot (polyin);
hold on
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Map Display에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by