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

2 visualizaciones (últimos 30 días)
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?

Respuestas (1)

Johan
Johan el 4 de Jul. de 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

Categorías

Más información sobre Graphics Object Properties en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by