超出可接受范围的嵌套 IF 和公式不起作用

Beyond acceptable range of Nested IF & formula not working

要检查的值

 |       | Northing | Easting |
 |-------|----------|---------|
 | Inst1 | 41345    | 33467.8 |
 | inst2 | 41600.5  | 33607.2 |
 | Inst3 | 41900.8  | 33740.2 |
 | Inst4 | 41933.4  | 33780   |
 | Inst5 | 41829.5  | 33694.6 |
 | Inst6 | 41449.9  | 33539   |

坐标范围

 |    | Northing |          | Easting |          |
 |----|----------|----------|---------|----------|
 | T1 | 41158.68 | 41396.88 | 33357.6 | 33517.57 |
 | T2 | 41307.9  | 41456.6  | 33384.2 | 33580.5  |
 | T3 | 41372.1  | 41517.5  | 33411.3 | 33607.5  |
 | T4 | 41431.6  | 41572.7  | 33435.8 | 33632.5  |
 | T5 | 41482.9  | 41654.6  | 33472.3 | 33654.2  |
 | S1 | 41564.9  | 41701.2  | 33493.1 | 33688.7  |
 | S2 | 41611.5  | 41762.3  | 33520.2 | 33708.3  |
 | S3 | 41672.7  | 41841.6  | 33555.5 | 33734.1  |
 | S4 | 41752.2  | 41897.9  | 33580.6 | 33767.6  |
 | S5 | 41809.3  | 41941.7  | 33600.1 | 33791.7  |
 | S6 | 41854.6  | 41998.7  | 33625.4 | 33810.7  |
 | T6 | 41914.8  | 42055.4  | 33650.7 | 33836.1  |
 | T7 | 41971.5  | 42137.4  | 33687.2 | 33859.9  |

嵌套 IF 显示的值不正确,不能超出第 48 行。

如何才能包含范围 M41:Q53?

下面的当前公式

=IF(N41<=$H<=O41 & P41<=$I<=Q41,M41,IF(N42<=$H<=O42 & 
P42<=$I<=Q42,M42,IF(N43<=$H<=O43 & 
P43<=$I<=Q43,M43,IF(N44<=$H<=O44 & 
P44<=$I<=Q44,M44,IF(N45<=$H<=O45 & 
P45<=$I<=Q45,M45,IF(N46<=$H<=O46 & 
P46<=$I<=Q46,M46,IF(N47<=$H<=O47 & 
P47<=$I<=Q47,M47,IF(N48<=$H<=O48 & P48<=$I<=Q48,M48,"Not 
here"))))))))

比较坐标时,坐标系的选择对逻辑的改变不大。 :-)

始终检查一个点是否在多边形内可能会很棘手(但并非不可能),但像这样的 普通矩形 很简单。如果您打算比较多个坐标,那么 nested If's 将不起作用。 (事实上​​ ,应始终避免使用它们!)

对于我的快速 n-dirty 示例,我获取了您的数据并将其放入列与行中,而不是并排放置。

公式为H6为:

=IF(AND(H>=MIN($C6:$D6),H<=MAX($C6:$D6),H>=MIN($E6:$F6),H<=MAX($E6:$F6)),"Match","-")

基本上就是检查:

  1. Northing To Match 是否大于或等于 到 NorthingStart 和 NorthingEnd 的 `MIN?

  2. Northing To Match 是否小于或等于`NorthingStart & NorthingEnd 的最大值?

    • 如果则点Northing to Match在指定的矩形内

还有许多其他方法可以解决这个问题。哪一个是正确的主要取决于你要比较多少数据,以及它是否是一个持续的需要(是否需要考虑不可预见的情况)...

数组公式.

的帮助下,并排数据集也可以完成同样的事情

进一步阅读:


还有一个切线(没有双关语意),但既然我提到它并且只是为了好玩,一个简短的解释:

如何检查给定点是在多边形内部还是外部?

1. Draw a horizontal line to the right of each point and extend it to infinity

2. Count the number of times the line intersects with polygon edges.

3. A point is inside the polygon if either count of intersections is odd or
   point lies on an edge of polygon.  If none of the conditions is true, then 
   point lies outside.

How to handle point g in the above figure?

Note that we should returns true if the point lies on the line or same as one of the vertices of the given polygon. To handle this, after checking if the line from p to extreme intersects, we check whether p is colinear with vertices of current line of polygon. If it is colinear, then we check if the point p lies on current side of polygon, if it lies, we return true, else false. (Source)