Is it possible to explode/expand a map? i.e. separate the countries by a given distance (such as exploding a pie chart)

2 vues (au cours des 30 derniers jours)
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?

Réponses (1)

Johan
Johan le 4 Juil 2022
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

Catégories

En savoir plus sur Graphics Object Properties dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by