GeoWithinQ[reg,loc]
GeoWithinQ[reg]
表示 GeoWithinQ 的操作符形式,可作用于一个位置.
GeoWithinQ
GeoWithinQ[reg,loc]
GeoWithinQ[reg]
表示 GeoWithinQ 的操作符形式,可作用于一个位置.
更多信息和选项
- 在 GeoWithinQ[reg,loc] 中,reg 可以指定为地理域的实体,如 "City"、"Country" 或 "HistoricalCountry";Dated[…] 对象;GeoVariant[…] 表达式或扩展的 GeoGraphics 基元. 位置 loc 还可以指定为 GeoPosition 或相关的类点位置对象.
- 对于与时间相关的实体,GeoWithinQ[reg,loc] 默认返回在它们历史上的某个时刻,loc 是否包含在 reg 中. 如果实体的时间跨度不同,则 GeoWithinQ 返回 False.
- Dated[entity,dates] 可用于将与时间相关的 entity 限制在给定的日期或日期间隔内. GeoVariant[entity,"UnionArea"] 可用于使计算忽略日期信息.
- GeoWithinQ 的两个参数都接受列表,事实上会在输入列表上调用 Outer.
- GeoWithinQ[reg][loc] 等价于 GeoWithinQ[reg,loc].
- GeoWithinQ 接受以下选项:
-
"FullyContained" False loc 是否被完全包含在 reg 中 TimeConstraint 20 最大计算时间(以秒为单位) - 选项设置 "FullyContained"->True 下,只有当 loc 完全包含在 reg 中时,GeoWithinQ[reg,loc] 才会返回 True.
范例
打开所有单元 关闭所有单元基本范例 (2)
GeoWithinQ[Entity["Country", "UnitedStates"], Entity["City", {"NewYork", "NewYork", "UnitedStates"}]]GeoWithinQ[Entity["AdministrativeDivision", {"Florida", "UnitedStates"}], Entity["City", {"NewYork", "NewYork", "UnitedStates"}]]GeoWithinQ[Entity["City", {"Champaign", "Illinois", "UnitedStates"}], Here]范围 (8)
地理数据 (5)
poly = Polygon[GeoPosition[{{40.42, -3.71}, {48.86, 2.34}, {52.52, 13.38}}]];
GeoWithinQ[poly, Entity["Country", "France"]]GeoGraphics[{Polygon[Entity["Country", "France"]], Red, poly}]GeoWithinQ[Entity["City", {"Chicago", "Illinois", "UnitedStates"}], {Entity["Airport", "KORD"], Entity["Airport", "KMDW"], Entity["Airport", "KBMI"], Entity["Airport", "KCMI"]}]GeoWithinQ[{EntityClass["Country", "NorthAmerica"], EntityClass["Country", "Europe"], Entity["Country", "UnitedStates"], Entity["Country", "France"], Entity["Country", "UnitedKingdom"]}, GeoPosition[{50.08, 14.43}]]GeoGraphics[GeoMarker[{50.08, 14.43}], GeoRange -> "Country"]GeoWithinQ[{EntityClass["Country", "NorthAmerica"], EntityClass["Country", "Europe"], Entity["Country", "UnitedStates"], Entity["Country", "France"], Entity["Country", "UnitedKingdom"]}, {Entity["City", {"Oxford", "Oxfordshire", "UnitedKingdom"}], Entity["City", {"Champaign", "Illinois", "UnitedStates"}], Entity["City", {"Lima", "Lima", "Peru"}], Entity["City", {"Frankfurt", "Hesse", "Germany"}]}]First[%] === GeoWithinQ[EntityClass["Country", "NorthAmerica"], {Entity["City", {"Oxford", "Oxfordshire", "UnitedKingdom"}], Entity["City", {"Champaign", "Illinois", "UnitedStates"}], Entity["City", {"Lima", "Lima", "Peru"}], Entity["City", {"Frankfurt", "Hesse", "Germany"}]}]使用 GeoWithinQ 的操作符形式:
GeoWithinQ[Entity["Country", "UnitedKingdom"]][Entity["City", {"Bath", "BathAndNorthEastSomerset", "UnitedKingdom"}]]历史数据 (3)
扎马战役(battle of Zama)发生时,该战役的地点还不在罗马共和国境内:
GeoWithinQ[Entity["HistoricalCountry", "RomanRepublic"], Entity["MilitaryConflict", "BattleOfZama"]]pos = GeoPosition[Entity["MilitaryConflict", "BattleOfZama"]]GeoWithinQ[Entity["HistoricalCountry", "RomanRepublic"], pos]GeoWithinQ[Dated[Entity["HistoricalCountry", "RomanRepublic"], -250], Entity["City", {"Paris", "IleDeFrance", "France"}]]GeoWithinQ[Dated[Entity["HistoricalCountry", "RomanRepublic"], -50], Entity["City", {"Paris", "IleDeFrance", "France"}]]GeoWithinQ[Entity["HistoricalCountry", "RomanEmpire"], Entity["HistoricalCountry", "RepublicVenice"]]GeoVariant[entity,"UnionArea"] 表示 entity 在其历史上所有时间的所有多边形的集合,因此 GeoWithinQ 可以忽略时间信息:
GeoWithinQ[GeoVariant[Entity["HistoricalCountry", "RomanEmpire"], "UnionArea"], Entity["HistoricalCountry", "RepublicVenice"]]选项 (2)
"FullyContained" (1)
GeoWithinQ[Entity["City", {"London", "GreaterLondon", "UnitedKingdom"}], Entity["Country", "UnitedKingdom"]]选项 "FullyContained"->True 排除了延伸到实体外的地区:
GeoWithinQ[Entity["City", {"London", "GreaterLondon", "UnitedKingdom"}], Entity["Country", "UnitedKingdom"], "FullyContained" -> True]GeoWithinQ[Entity["Country", "UnitedKingdom"], Entity["City", {"London", "GreaterLondon", "UnitedKingdom"}], "FullyContained" -> True]TimeContraint (1)
GeoWithinQ[Entity["Country", "UnitedStates"], Entity["AdministrativeDivision", {"California", "UnitedStates"}], TimeConstraint -> 0.1]GeoWithinQ[Entity["Country", "UnitedStates"], Entity["AdministrativeDivision", {"California", "UnitedStates"}]]应用 (1)
points = {GeoPosition[{40.38, -95.32}], GeoPosition[{35.44, -111.98}], GeoPosition[{37.11, -93.83}], GeoPosition[{45.16, -111.35}], GeoPosition[{44.67, -75.44}]};group = GeoGroup[{Entity["AdministrativeDivision", {"Missouri", "UnitedStates"}], Entity["AdministrativeDivision", {"Illinois", "UnitedStates"}], Entity["AdministrativeDivision", {"Iowa", "UnitedStates"}], Entity["AdministrativeDivision", {"Kansas", "UnitedStates"}]}];GeoWithinQ[group, points]属性和关系 (2)
GeoWithinQ[list1,list2] 实际上等价于 Outer[GeoWithinQ,list1,list2]:
GeoWithinQ[{EntityClass["Country", "NorthAmerica"], EntityClass["Country", "Europe"]}, {Entity["City", {"Oxford", "Oxfordshire", "UnitedKingdom"}], Entity["City", {"Champaign", "Illinois", "UnitedStates"}], Entity["City", {"Lima", "Lima", "Peru"}]}] === Outer[GeoWithinQ, {EntityClass["Country", "NorthAmerica"], EntityClass["Country", "Europe"]}, {Entity["City", {"Oxford", "Oxfordshire", "UnitedKingdom"}], Entity["City", {"Champaign", "Illinois", "UnitedStates"}], Entity["City", {"Lima", "Lima", "Peru"}]}]GeoWithinQ 可以使用 GeoNearest 和 MemberQ 的组合实现:
continentalUS = GeoVariant[Entity["Country", "UnitedStates"], "DefaultMapArea"];
point = GeoPosition[{33.92, -118.71}];
GeoWithinQ[continentalUS, point]MemberQ[GeoNearest[{continentalUS}, point, {All, 0}], continentalUS]GeoNearest 允许指定半径:
MemberQ[GeoNearest[{continentalUS}, point, {All, Quantity[100, "Kilometers"]}], continentalUS]GeoGraphics[{PointSize[Large], Point@point}]可能存在的问题 (2)
如果使用默认选项值 "FullyContained"False,GeoWithinQ 将会检查多边形交叉的情况,可能会导致意外结果:
GeoWithinQ[Entity["GeographicRegion", "Africa"], Entity["Country", "Spain"]]默认情况下,GeoWithinQ 使用国家的 "PrincipalArea" 地理变体, 其中,西班牙将包含加那利群岛:
GeoGraphics[{Polygon[Entity["GeographicRegion", "Africa"]], GeoStyling[Red], Polygon[GeoVariant[Entity["Country", "Spain"], "PrincipalArea"]]}, GeoCenter -> Entity["Island", "Lanzarote"], GeoRange -> Quantity[300, "Miles"]]用 "FullyContained"True 检查实际的情况:
GeoWithinQ[Entity["GeographicRegion", "Africa"], Entity["Country", "Spain"], "FullyContained" -> True]GeoWithinQ[Entity["GeographicRegion", "Africa"], GeoVariant[Entity["Country", "Spain"], "DefaultMapArea"]]GeoWithinQ[entity,loc] 使用可用于给定实体的边界多边形,该边界多边形可能没有足够的分辨率来正确解析某些位置,尤其是靠近海岸的地方:
loc = Interpreter["Location"]["brooklyn bridge"]GeoGraphics[{Polygon[Entity["Country", "UnitedStates"]], GeoMarker[loc]}, GeoCenter -> loc, GeoRange -> Quantity[3, "Miles"]]因此,该受限的 Interpreter 调用失败:
Interpreter[Restricted["Location", Entity["Country", "UnitedStates"]]]["brooklyn bridge"]Interpreter[Restricted["Location", Entity["City", {"NewYork", "NewYork", "UnitedStates"}]]]["brooklyn bridge"]GeoGraphics[{Polygon[Entity["City", {"NewYork", "NewYork", "UnitedStates"}]], GeoMarker[loc]}]文本
Wolfram Research (2014),GeoWithinQ,Wolfram 语言函数,https://reference.wolfram.com/language/ref/GeoWithinQ.html (更新于 2024 年).
CMS
Wolfram 语言. 2014. "GeoWithinQ." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2024. https://reference.wolfram.com/language/ref/GeoWithinQ.html.
APA
Wolfram 语言. (2014). GeoWithinQ. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/GeoWithinQ.html 年
BibTeX
@misc{reference.wolfram_2026_geowithinq, author="Wolfram Research", title="{GeoWithinQ}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/GeoWithinQ.html}", note=[Accessed: 03-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_geowithinq, organization={Wolfram Research}, title={GeoWithinQ}, year={2024}, url={https://reference.wolfram.com/language/ref/GeoWithinQ.html}, note=[Accessed: 03-November-2026]}