現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
Where is the polyIntersect.m function in R2024 and how do I load it ?
2 ビュー (過去 30 日間)
古いコメントを表示
I have updated my R2022 license and can't locate the polyIintersect.m function and load it ? I need the function
for an old program
採用された回答
Star Strider
2024 年 7 月 2 日
I can’t find it in the online documentation. There are several Mapping Toolbox functions, specifically polyxpoly, as well as other intersection functions.
To the best of my knowledge, thater are none in core MATLAB, although there are several in the File Exchange.
その他の回答 (1 件)
Walter Roberson
2024 年 7 月 2 日
polyintersect appears to be part of MRST (MATLAB Resevoir Simulation Toolbox), https://www.sintef.no/contentassets/2551f5f85547478590ceca14bc13ad51/nwm.html
16 件のコメント
Chuck Dalby
2024 年 7 月 2 日
Thank you. I downloaded and located the function in the Reservoir Simulation Toolbox, but am not sure how to load it into MATLAB. The read.me file is thin and I am new to MATLAB. I am still surprised that polyintersect is not a standard mapping function. Is there another way to accomplish this without using polyintersect ?
Chuck Dalby
2024 年 7 月 3 日
Here is the foemer code that worked in R2022:
[OutData(ii).intsecArea(i).Data, S] = polyIntersect(CoRegErrData, inPolyNewsub, inPolyOldsub)
If I change this to:
[OutData(ii).intsecArea(i).Data, S] = Intersect(CoRegErrData, inPolyNewsub, inPolyOldsub)
I get the error message:
Error in polyshape/intersect (line 68)
ns = polyshape.checkArray(subject);
Error in SDP_Sprinkler_preallocate_1a (line 33)
[OutData(ii).intsecArea(i).Data, S] = intersect(CoRegErrData, inPolyNewsub, inPolyOldsub);
Steven Lord
2024 年 7 月 3 日
That's not the full text of the error message. Please show all the text displayed in red (and/or orange) when you run that code.
Depending on exactly what your polyintersect function did, intersect may not be a strict "find and replace" replacement. The exact text of the message may tell us what you need to do to modify your code to use it.
Chuck Dalby
2024 年 7 月 3 日
Here it is:
Warning: Polyshape has duplicate vertices, intersections, or other inconsistencies that may produce inaccurate or unexpected results. Input data has been modified to create a well-defined polyshape.
> In polyshape/checkAndSimplify (line 526)
In polyshape (line 175)
In SDP_Sprinkler_preallocate_1a (line 23)
Error using polyshape/checkArray (line 562)
First input argument must be of type polyshape.
Error in polyshape/intersect (line 68)
ns = polyshape.checkArray(subject);
Error in SDP_Sprinkler_preallocate_1a (line 33)
[OutData(ii).intsecArea(i).Data, S] = intersect(CoRegErrData, inPolyNewsub, inPolyOldsub);
Steven Lord
2024 年 7 月 3 日
Okay, so what exactly is CoRegErrData? Nothing in the code you've posted shows what it is. If it's not a polyshape object but it represents a polygonal region, make a polyshape using that data and then call intersect.
Chuck Dalby
2024 年 7 月 3 日
CoRegErrData.mat is a data file that contains 2-D contour maps of horizontal positional error (x,y)-- the data convers the state of Montana so it is a polygonal region (I think?). I will try what you suggest.
Walter Roberson
2024 年 7 月 3 日
Sorry, I was not able to find any polyIntersect function anywhere -- only polyintersect
Chuck Dalby
2024 年 7 月 4 日
Is the polyintersect function only available with the Reservoir Simulation Toolbox ?
Chuck Dalby
2024 年 7 月 4 日
Thanks. I downloaded and extracted the LabelMeToolbox, but can't install it using the add on manager--it does not appear on the selection of available add ons--please advise
Walter Roberson
2024 年 7 月 4 日
Or just copy the individual polyintersect.m into your current directory.
Chuck Dalby
2024 年 7 月 4 日
I copied polyintersect.m into the current directory and the program ran but with these error messages:
Warning: Polyshape has duplicate vertices, intersections, or other inconsistencies that may produce inaccurate or unexpected results. Input data has been modified to create a well-defined polyshape.
> In polyshape/checkAndSimplify (line 526)
In polyshape (line 175)
In SDP_Sprinkler_1 (line 23)
I have had no problem with the simplify process below, but get the error message below--I have attached the full code for context
:
Error using vertcat
The following error occurred converting from struct to polyshape:
x- and y-coordinate vectors must both be numeric or both be cell arrays.
Error in polyintersect (line 8)
min_x = min([X1(:); X2(:)]);
Error in SDP_Sprinkler_1 (line 36)
[OutData(ii).intsecArea(i).Data, S] = polyintersect(CoRegErrData, inPolyNewsub, inPolyOldsub);
%% Load Data
inFiles = readtable('C:\MT_Conversion_Flood_to_Sprinkler\SDP\SDP_Project\inFiles\Overlays_S.xlsx');
dataFolder = 'C:\MT_Conversion_Flood_to_Sprinkler\SDP\SDP_Project\data_folder\';
load('C:\MT_Conversion_Flood_to_Sprinkler\SDP\SDP_Project\CoRegErrData.mat')
%% set subset
hucPoly = shaperead('C:\MT_Conversion_Flood_to_Sprinkler\SDP\SDP_Project\HUC4_Montana.shp');
%'C:\Users\kintla\Documents\SDP_Files\HUC4_Montana.shp']);
%% Run analysis
for ii = 1:length(hucPoly)
hucSub = polyshape(hucPoly(ii).X, hucPoly(ii).Y);
hucID = hucPoly(ii).Name;
OutData(ii).hucID = hucID;
for i = 1:size(inFiles,1)
inShapeOld = shaperead([dataFolder char(inFiles.OldShape(i))]);
inPolyOld = polyshape([inShapeOld.X],[inShapeOld.Y], 'Simplify', false);
inShapeNew = shaperead([dataFolder char(inFiles.NewShape(i))]);
inPolyNew = polyshape([inShapeNew.X],[inShapeNew.Y], 'Simplify', false);
inPolyNewsub = intersect(inPolyNew, hucSub,'KeepCollinearPoints',true);
inPolyOldsub = intersect(inPolyOld, hucSub);
[OutData(ii).intsecArea(i).Data, S] = polyintersect(CoRegErrData, inPolyNewsub, inPolyOldsub);
OutData(ii).intsecArea(i).ID = char(inFiles.NewShape(i));
if ~isnan(S(1).X(1))
shapewrite(S, [dataFolder 'outShapes_S\' hucID '_outInt_' char(inFiles.NewShape(i))])
end
T = table(OutData(ii).intsecArea(i).Data, 'VariableNames', {'outInt_acres1' });
writetable(T, [dataFolder 'outTables_S\' hucID '_outInt_' char(inFiles.NewShape(i)) '.txt'])
end
end
Steven Lord
2024 年 7 月 4 日
Use your coordinate data from the CoRegErrData struct to create polyshape objects. Then just use intersect.
Chuck Dalby
2024 年 7 月 5 日
The CoRegErrData file is large (7GB) and I am not sure how to create the polyshape objects ?
Chuck Dalby
2024 年 7 月 6 日
Hmmmm. If one looks at the code above it contains conversion of the data to polyshape objects ?
inPolyOld = polyshape([inShapeOld.X],[inShapeOld.Y], 'Simplify', false);
inShapeNew = shaperead([dataFolder char(inFiles.NewShape(i))]);
inPolyNew = polyshape([inShapeNew.X],[inShapeNew.Y], 'Simplify', false);
So I don't understand the need to do so again ?
参考
カテゴリ
Help Center および File Exchange で Elementary Polygons についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)