bufferm works differently with the same data sets?

4 views (last 30 days)
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:

Accepted Answer

Harikrishnan Balachandran Nair
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 Comment
Faez Alkadi
Faez Alkadi on 2 Dec 2021
Edited: Faez Alkadi on 2 Dec 2021
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

Sign in to comment.

More Answers (0)

Categories

Find more on Earth and Planetary Science in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!