Create a polygon based on the location of points
Show older comments
Hi, I would like to create a polygon based on the location of all the volcanoes contained inside the boundaries of South America. This polygon will be created automatically considering a radius of 15km for each volcano and then extract the envelop of the georeferenced polygon (that contains all the surrounded volcanos) like the highlighted are in the following image:
The code to obtain the plot of the South America continent and the location of volcanoes is the following: load volcanic.mat
% loading the volcanic data which is attached to this message
% Step 1: Create a map of South America
figure;
ax = worldmap('South America'); % Create a map focused on South America
setm(ax, 'FFaceColor', [0.9 0.9 0.9]); % Set background color
title('Volcano Locations in South America');
% Step 2: Add a basemap
land = shaperead('landareas', 'UseGeoCoords', true);
geoshow(ax, land, 'FaceColor', [0.5 0.7 0.5]); % Display land areas
% Step 3: Define volcano locations (example coordinates)
volcanoLat = volcanic.lat; % Latitudes of volcanoes volcano
Lon = volcanic.lon; % Longitudes of volcanoes
% Step 4: Plot volcanoes
geoshow(volcanoLat, volcanoLon, 'DisplayType', 'point', ...
'Marker', 'o', 'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'r', ...
'MarkerSize', 6);
%textm(volcanoLat, volcanoLon, {'Volcano1', 'Volcano2', 'Volcano3', 'Volcano4', 'Volcano5'}, ...
% 'VerticalAlignment', 'bottom', 'HorizontalAlignment', 'right');
% Optional: Add grid and refine details
gridm on; mlabel on; % Show latitude labels
plabel on; % Show longitude labels
I would appreciate the help.
2 Comments
jinjin lee
on 16 Dec 2024
figure;
ax = worldmap('South America'); % Create a map focused on South America
setm(ax, 'FFaceColor', [0.9 0.9 0.9]); % Set background color
title('Volcano Locations in South America');
% Step 2: Add a basemap
land = shaperead('landareas', 'UseGeoCoords', true);
geoshow(ax, land, 'FaceColor', [0.5 0.7 0.5]); % Display land areas
% Step 3: Define volcano locations (example coordinates)
volcanoLat = volcanic.lat; % Latitudes of volcanoes
volcanoLon = volcanic.lon; % Longitudes of volcanoes
% Step 4: Plot volcanoes
geoshow(volcanoLat, volcanoLon, 'DisplayType', 'point', ...
'Marker', 'o', 'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'r', ...
'MarkerSize', 6);
bufwidth = 0.1;
[latb, lonb] = bufferm(volcanoLat, volcanoLon, bufwidth);
geoshow(latb, lonb, 'DisplayType', 'polygon', ...
'FaceColor', 'yellow')
Jorge Luis
on 17 Dec 2024
Accepted Answer
More Answers (0)
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!