how to generate points inside a polygon using a .kml file aqcuired by google earth ?

2 visualizaciones (últimos 30 días)
hello i have this following code generates a set number of points (n) respecting fermat spiral pattern, what i want is to distribute these (n) points inside a polygonal shape in other words these points should be constrained by specific boundaries. the shape is a .kml file aqcuired from google earth i want to modify this code in a way that it could import the shape from the .kml file and generate these points inside it. i would be thankful if i can get some help
% Generation of points coordinates
D1=10; Dm=100; n=2500;
r = zeros(1, n);
teta = zeros(1, n);
x = zeros(1, n);
y = zeros(1, n);
k = 1;
curpoint = 1;
while curpoint <= n
r(curpoint) = a*k^b;
%Minimum radial distance to the center
if r(curpoint) > D1
teta(curpoint) = 2*pi*(phi^-2)*k;
[x(curpoint), y(curpoint)] = pol2cart(teta(curpoint), r(curpoint));
%Only add this point if it is far enough away from all others
if curpoint == 1 || all(hypot(x(curpoint) - x(1:curpoint-1), y(curpoint) - y(1:curpoint-1)) >= Dm)
curpoint = curpoint + 1;
end
end
k = k + 1;
end
  2 comentarios
Jan
Jan el 11 de Mayo de 2018
I do not understand the first sentence: " i want to create a (n) points according to fermat spiral equations, respecting two conditions a minimum radial distance D1, and no overlaping between points Dm, inside a specific polygon (.kml file) acquired using Google Earth."
Please elaborate this to make it more clear. You mention a kml file, but I do not see in teh code, where this matters.
zouhir zeroual
zouhir zeroual el 11 de Mayo de 2018
the above code generate a set number of points (n) respecting fermat spiral pattern, my objectif is to distribute these (n) points inside a polygonal shape in other words these points should be constrained by specific boundaries. the shape is a .kml file aqcuired from google earth i want to modify this code in a way that it could import the shape from the .kml file and generate these points inside it

Iniciar sesión para comentar.

Respuestas (1)

KSSV
KSSV el 11 de Mayo de 2018
Editada: KSSV el 11 de Mayo de 2018
Read about inpolygon. This is your friend now to generate points inside the polygon. Check the below pseudo code.
% some closed figure
x = rand(3,1) ;
y = rand(3,1) ;
x(4) = x(1) ; y(4) = y(1) ;
plot(x,y)
hold on
%%Generate points inside closed figure
N = 100 ;
xx = linspace(min(x),max(x),N) ;
yy = linspace(min(y),max(y),N) ;
[X,Y] = meshgrid(xx,yy) ;
%%GEt points inside the closed figure
idx = inpolygon(X(:),Y(:),x,y) ;
plot(X(idx),Y(idx),'.b') ;
plot(X(~idx),Y(~idx),'.r') ;

Categorías

Más información sobre Google Earth en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by