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
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!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 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 (한국어)