achieving a weighted inpolygon function

조회 수: 1 (최근 30일)
PIETRO DEVÒ
PIETRO DEVÒ 2022년 1월 9일
댓글: PIETRO DEVÒ 2022년 1월 10일
Hi,
I have a n x m array, which represents a space of discrete cells, all equal to each other and with a defined spatial size, dx x dy. In each entry of the array I can have a certain parameter, that I will later need to evaluate.
I then have a boundary curve, defined by x and y vectors, that I use to define a study region, closed and spatially homogeneous with the sizes of cells, so that my coordinates are in a range of 0 to n*dx and 0 to m*dy.
Creating the meshgrids, I can succesfully use the inpolygon function to obtain the matrix of internal cells.
What I would also like to obtain is a matrix of weighted membership of each cell to the region defined by the boundary curve, so that I have a number from 0 (fully outside) to 1 (fully inside) that gives me essentially the percentage of area included inside that region for each cell.
What are the possibile ways to achieve that?
Thank you in advance

채택된 답변

Matt J
Matt J 2022년 1월 9일
편집: Matt J 2022년 1월 9일
If the cells and the study region are represented by polyshape objects,
you can use the polyshape.intersect() and polyshape.area() methods to find the intersection areas, and percentage areas.
  댓글 수: 1
PIETRO DEVÒ
PIETRO DEVÒ 2022년 1월 10일
This definitely did the trick!
Being short: starting from an NC file, with longitude, latitude, time and my parameter (precipitation), I produced a normalized x-y cell system of my problem, like that:
Where there is the little polyshape of my study region.
I essentialy used inpolygon function to identify firstly the "strictly included" barycentres of cells, then a combination of inpolygon to relative offsets of study region to add the "partially included" barycentres, obtaining:
Now, indexing that involved cells in a vector let me iterate cells in the original array of data to extract the parameter of interest. The intersect and area function, applied to each cell-region combination, evaluate the weight, achieving the objective.
Thank you very much.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2022년 1월 9일
Not sure I understand. A diagram would help.
All I can guess is that the bwdist() function, to get the Euclidean distance from a point to the edge/boundary, or the regionfill() function might help.
  댓글 수: 1
PIETRO DEVÒ
PIETRO DEVÒ 2022년 1월 10일
Thank you for the answer, and sorry for not being clear.
This is an interesting method, I will try to implement also that way!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Smoothing에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by