How to calculate the coordinates of the overlaped points over a polygon?

1 次查看(过去 30 天)
The example on which i tried to apply the inpolygon is:
solux=[5.95,6.40,6.2,6.3,6.42,6.81,7.26,7.76,6.5,8.1,8.17,8.6,9.06,9.5,8.1]
and soluy = [37.5,37.3,36.8,36.3,35.8,35.5,35.3,35.3,35.1,35.02,34.5,35.07,34.7,34.7,34.02];
and the coodinates of polygon is attached in the attachment. I have used the 'inpolygon(solux,soluy,xv,yv)' to solve the problem, but im unable to draw the coordinates of the polygon into 'xv' and 'xy'. Please find the files for coordinates of the polygon in 'trialdataofcoordinates.mat' file. Please help me out.

回答(1 个)

DGM
DGM 2025-7-5
编辑:DGM 2025-7-5
Plot the data and look at it. The data points don't appear to be anywhere near the polygons.
% the data
load trialdataofcoordinates.mat
solux = [5.95,6.40,6.2,6.3,6.42,6.81,7.26,7.76,6.5,8.1,8.17,8.6,9.06,9.5,8.1];
soluy = [37.5,37.3,36.8,36.3,35.8,35.5,35.3,35.3,35.1,35.02,34.5,35.07,34.7,34.7,34.02];
% plot the points
scatter(solux,soluy); hold on
% plot the pgons and calculate intersection
isinpgon = false(numel(mycoordinates),numel(solux));
for k = 1:numel(mycoordinates)
plot(mycoordinates{k}(:,1),mycoordinates{k}(:,2),'k') % assuming these are [x y]
isinpgon(k,:) = inpolygon(solux,soluy, ...
mycoordinates{k}(:,1),mycoordinates{k}(:,2));
end
% clearly, none of the points are in any of the pgons
nnz(isinpgon)
ans = 0

类别

Help CenterFile Exchange 中查找有关 Geoscience 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by