Borrar filtros
Borrar filtros

how to deal with large polygons ?

3 visualizaciones (últimos 30 días)
Reema Alhassan
Reema Alhassan el 1 de Jul. de 2018
Respondida: Anton Semechko el 1 de Jul. de 2018
hello everyone, I'm using geoimread() to read the image with the x and y coordinates of each polygon. and then I extract the x and y coordinates of each polygon and use inpolygon() to intersect the coordinates of the image and the polygon but if the polygon was large the inpolygon() doesn't give a result (the program is is busy for a long time)
is there a function faster than inpolygon()? or is there a way to divide the polygon to small polygons and process each one alone? the code is working when I intersect small polygons with the image only. in the attachment you can find a screen shot of the shape and the stalliate image
here is my code for more info:
shape = shaperead(fullfile('KTAF_sat_shapefiles','shapefiles','SAU1.shp'));
numOfpolygons=size(shape,1);
total=0;
for i=1:numOfpolygons
[A,x,y,I] =geoimread('SVDNB_npp_20150201-20150228_75N060W_vcmcfg_v10_c201504281504.avg_rade9h.tif',shape(i).X,shape(i).Y);
rx = shape(i).X(1:end-1);
ry = shape(i).Y(1:end-1);
[X,Y] = meshgrid(x,y);
mask =inpolygon(X,Y,rx,ry);
result= mask.*A;
sumOfValues= sum(result(:));
total=total+sumOfValues;
sumOfValues1=sprintf('%f', sumOfValues)
end
disp('The total:');
sumOfValues1=sprintf('%f',total)

Respuestas (1)

Anton Semechko
Anton Semechko el 1 de Jul. de 2018
Included in the above submission is 'DecimatePoly_demo3' function, which demonstrates how 'DecimatePoly' can be used to improve run-time of in-polygon tests at the cost of minor misclassification errors.

Categorías

Más información sobre Elementary Polygons 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