Connecting points to polygon

6 visualizaciones (últimos 30 días)
Debora Baumann
Debora Baumann el 13 de En. de 2024
Comentada: Debora Baumann el 20 de En. de 2024
Hi,
i'm currently struggling with following issue: I have a table geometry_points_outline which stores the outline of a geometry as point coordinates x and y. the geometry consists of three seperate polygons. I'm able to connect the points with the following code section:
for i = 1:height(geometry_points_outline)
nearestPoints = nearestIndices(i, :);
plot([geometry_points_outline.xCoordinates(i), geometry_points_outline.xCoordinates(nearestPoints(2))], ...
[geometry_points_outline.yCoordinates(i), geometry_points_outline.yCoordinates(nearestPoints(2))], 'k-', 'LineWidth', 2);
plot([geometry_points_outline.xCoordinates(i), geometry_points_outline.xCoordinates(nearestPoints(3))], ...
[geometry_points_outline.yCoordinates(i), geometry_points_outline.yCoordinates(nearestPoints(3))], 'k-', 'LineWidth', 2);
end
I have another table which stores regular space grid points. Now i want to do two things:
  1. filling the space between the lines so the geometry is represented clearly.
  2. Find the points of the grid which lie between these lines and and delete them from the grid table.
I tried various things, including drawing a polygon manually or selecting the points manually, but the have not been successful. Do you have any idea how to solve this issue?
I attached both tables as csv files.
Thanks for your help!

Respuesta aceptada

Matt J
Matt J el 13 de En. de 2024
Editada: Matt J el 13 de En. de 2024
Your code can't be run because nearestIndices is not provided.
Regardless, I would recommend using polyshape to represent and plot the polygons. Likewise isinterior can be used to assess whether points lie inside the polygons.
  20 comentarios
Matt J
Matt J el 19 de En. de 2024
Editada: Matt J el 19 de En. de 2024
Here's an altenative implementation of mkpshape, which uses this FEX download,
It seems to work quite well.
function p=mkpshape(x,y,G)
%Trace the boundary of the given points and convert to polyshapes
x=x(G); y=y(G);
pth = tspsearch([x,y],5);
p=polyshape(x(pth),y(pth),'Simplify',0);
end
Also, you need to fix the computation of G3,
G3=XY1*L2 > 0;
Debora Baumann
Debora Baumann el 20 de En. de 2024
Amazing, thanks for your effort!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Properties en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by