필터 지우기
필터 지우기

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?

답변 (1개)

Johan
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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by