フィルターのクリア

How I can count the number lines falling inside the green region

1 回表示 (過去 30 日間)
Ritesh
Ritesh 2024 年 2 月 6 日
コメント済み: Image Analyst 2024 年 2 月 7 日
figure(2);
rows = 1;
columns = 1;
for subplotIndex = 1 : rows * columns
subaxis(rows, columns, subplotIndex, 'spacing', 0.01, 'margin', 0.01);
m_proj('stereographic', 'lat', 90, 'long', 30, 'radius', 30.1);
m_coast('patch', [.7 .7 .7], 'edgecolor', 'k');
m_grid('xtick', -180:90:180, 'tickdir', 'out', 'ytick', [70 80], 'linest', '-');
end
hold on;
a = 'F:\hysplit_output\ny_alesund\ny_18_19_djf\*.';
files = dir(a);
for jj = 1:numel(files)
fullFilePath = fullfile(files(jj).folder, files(jj).name);
if ~files(jj).isdir
headerLines = 7;
data = readtable(fullFilePath, 'HeaderLines', headerLines);
X = data.Var11;
Y = data.Var10;
[X_map, Y_map] = m_ll2xy(X, Y);
plot(X_map, Y_map, '-b', 'LineWidth', 0.1);
hold on;
M = m_shaperead('first_r');
for k = 1:length(M.ncst)
m_line(M.ncst{k}(:,1), M.ncst{k}(:,2), 'linewidth', 4, 'color', 'g');
end
[xi, yi] = polyxpoly([X_map, Y_map].', [M.ncst{1}(:, 1), M.ncst{1}(:, 2)].');
end
end
  3 件のコメント
Ritesh
Ritesh 2024 年 2 月 7 日
@Catalytic I am sorry, but I am beginer
Image Analyst
Image Analyst 2024 年 2 月 7 日
Does your code require the mapping toolbox?

サインインしてコメントする。

回答 (1 件)

Matt J
Matt J 2024 年 2 月 6 日
編集済み: Matt J 2024 年 2 月 6 日
green=polyshape(vertcat(M.ncst));
Lines=findobj(gca,'Type','line');
clear insideGreen
for i=numel(Lines):-1:1
points=[Lines(i).XData;Lines(i).YData]';
insideGreen(i)= any(isinterior(green,points));
end
total=sum(insideGreen)

カテゴリ

Help Center および File ExchangeMap Display についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by