检查坐标点是否位于特定的盒子区域python [英] Check if a coordinate point are lies in certain box area python
问题描述
我有一个地点的坐标点,例如:
I have a coordinate point of a place, for example:
point_coord = [-7.7938593,110.3634829]
我还有一个区域的 viewport
,其中包含两个点,例如:
I also have a viewport
of an area contain two point of corrdinates, for example:
northeast = [5.9052479,141.0194444]
southwest = [-11.005261,95.01106190000002]
如果我说明了这一点,它将看起来像这样:
If I illustrate these point, it will be look like this:
问题是,如何使用Python检查 point_coord
是否掉落或位于该盒子区域中的某处?
The question is, how do I check if the point_coord
is fall or lies in somewhere in that box area using Python?
谢谢
推荐答案
对不起,在地图和视口方面没有太多经验,但不应该仅仅是:
Sorry, not too much experience with maps and viewports, but shouldn't it simply be:
def isInside(point_coord, northeast, southwest):
return southwest[0]<point_coord[0]<northeast[0] and\
southwest[1]<point_coord[1]<northeast[1]
我能想到的唯一可能的极端情况是北极和南极.您可能只需要编写特殊情况下的代码即可处理它们.
The only possible edge cases I can think of would be north and south poles. You could probably just code special cases to handle them.
一些错别字,而不是链接比较.
some typos and not chaining comparisons.
这篇关于检查坐标点是否位于特定的盒子区域python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!