# Count how many points are in the polygon

Yu Wing Ha shared this question 1 year ago

Hello!

I want to count how many points are in the polygon (include vertice and any point like the image point inside the polygon. 3

Place all the points to be considered in a list (Li1).

Then use the following command:

countInPoly1 = Sum(Zip(IsInRegion(P, poly1), P, Li1)) 1

I have followed your guidance to create the list (Li1).

countInPoly1=Sum(Zip(IsInRegion(P,poly1),P,Li1))

Thank you very much! 2

P has its scope only within Zip. P is the name (freely selectable) of 1 element within Li1. With each element of Li1, P is passed to the first parameter (expression) of Zip. See also the manual.

In other words: All elements of Li1 are checked if they are inside poly1. This results in a list of boolean values which are interpreted as 1=true or 0=false with the function Sum(). 2

You can also use:

`CountIf(IsInRegion(P,poly1),P,Li1)`

Again, P is a parameter only defined within the scope of the CountIf - it does not need to be pre-existing. 