Is it possible to explode/expand a map? i.e. separate the countries by a given distance (such as exploding a pie chart)
조회 수: 2 (최근 30일)
이전 댓글 표시
I have this .shp file which represents the map of Italy, where each row represents a single region
I'm able to plot it using the built-in function mapshow, but now I'd like to explode the map, i.e. plot the same map but with all the regions separated by a given distance, let's say 5 pixels. Basically I'd like to obtain the same effect as when we explode a pie chart
Is this possible with the matlab functions or we should manually edit the X, Y coordinates of each region?
댓글 수: 0
답변 (1개)
Johan
2022년 7월 4일
You could scale the regions around there geometric centers. There are builtin matlab tool using the polyshape structure that can do so relatively easily:
square = polyshape([0,1,1,0],[1,1,0,0]); % create a template square
%Translation matrix to create 4 contiguous regions
Translatation_matrix = [0,1,1,0;...
0,0,1,1];
%initialize data structure
data(1:length(Translatation_matrix)) = struct('shape',polyshape());
scaleddata = data;
%Translate template according to Translatation_matrix and fill results in
%data structure
for i_shape = 1:length(Translatation_matrix)
data(i_shape).shape = translate(square,Translatation_matrix(:,i_shape)');
end
figure(1)
plot([data.shape])
axis equal
% Using centroid and scale on the translated square, they now have a gap
% between each contiguous regions
for i_shape = 1:length(Translatation_matrix)
[X,Y] = centroid(data(i_shape).shape);
scaleddata(i_shape).shape = scale(data(i_shape).shape, 0.95,[X,Y]);
end
figure(2)
plot([scaleddata.shape])
axis equal
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!