bufferm works differently with the same data sets?

4 ビュー (過去 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 Center および File ExchangeMap Display についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by