I have a MATLAB 2022 code that used the poly.intersect function–I can’t find in R2024 and need a workaround
I have a MATLAB 2022 code that used the poly.intersect function–I can’t find in R2024 and need a workaround to compute the intersection of polygons. The code is below. In line 12 the polyIntersect function is used:
[OutData(ii).intsecArea(i).Data, S] = polyIntersect(CoRegErrData, inPolyNewsub, inPolyOldsub);
How do I modify the code in lieu of using polyIntersect ?
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’])
endI have a MATLAB 2022 code that used the poly.intersect function–I can’t find in R2024 and need a workaround to compute the intersection of polygons. The code is below. In line 12 the polyIntersect function is used:
[OutData(ii).intsecArea(i).Data, S] = polyIntersect(CoRegErrData, inPolyNewsub, inPolyOldsub);
How do I modify the code in lieu of using polyIntersect ?
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 I have a MATLAB 2022 code that used the poly.intersect function–I can’t find in R2024 and need a workaround to compute the intersection of polygons. The code is below. In line 12 the polyIntersect function is used:
[OutData(ii).intsecArea(i).Data, S] = polyIntersect(CoRegErrData, inPolyNewsub, inPolyOldsub);
How do I modify the code in lieu of using polyIntersect ?
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 poly.intersect MATLAB Answers — New Questions