GeoWithinQ

GeoWithinQ[reg,loc]

returns True if the location loc is contained within the region reg, and False otherwise.

GeoWithinQ[reg]

represents an operator form of GeoWithinQ that can be applied to a location.

Details and Options

  • In GeoWithinQ[reg,loc], reg can be specified as an entity of a geo domain such as "City", "Country" or "HistoricalCountry"; a Dated[] object; a GeoVariant[] expression or an extended GeoGraphics primitive. The location loc can additionally be specified as a GeoPosition or related point-like location object.
  • For time-dependent entities, GeoWithinQ[reg,loc] returns by default whether loc is contained in reg at some moment in their history. If the entities have different time spans, then GeoWithinQ returns False.
  • Dated[entity,dates] can be used to restrict a time-dependent entity to a given date or interval of dates. GeoVariant[entity,"UnionArea"] can be used to make the computation ignore date information.
  • GeoWithinQ accepts lists in both arguments, effectively calling Outer on the input lists.
  • With the option setting "FullyContained"->True, GeoWithinQ[reg,loc] will return True only if loc is completely contained in reg.
  • GeoWithinQ[reg][loc] is equivalent to GeoWithinQ[reg,loc].

Examples

open allclose all

Basic Examples  (2)

New York City is in the United States:

But it is not in the state of Florida:

Determine if your current location is Champaign, Illinois:

Scope  (8)

Geographic Data  (5)

Test whether France is included in the following polygon:

Visualize France and the polygon:

Test whether several airports are inside the city of Chicago:

Test whether a particular location is inside several different regions:

Test several cities for membership in several regions simultaneously:

Each row is the result for all locations with respect to a single region:

Use GeoWithinQ as an operator form:

Historical Data  (3)

The location of the battle of Zama was not yet in the Roman Republic when the battle took place:

The location of the battle of Zama was in the Roman Republic later in time:

The location of the city of Paris was not in the Roman Republic in year 250 BC:

It was included in the Roman Republic in year 50 BC:

The Republic of Venice was never in the Roman Empire because they did not overlap in time:

GeoVariant[entity,"UnionArea"] represents the union of all polygons of entity at all times in its history, making GeoWithinQ ignore temporal information:

Options  (1)

"FullyContained"  (1)

The United Kingdom is considered to be inside London, since the two entities overlap:

The option "FullyContained"->True excludes regions that extend outside the entity:

London is always considered to be inside the United Kingdom:

Applications  (1)

Determine which of several points are in a group of central states of the United States:

Properties & Relations  (2)

GeoWithinQ[list1,list2] is essentially equivalent to Outer[GeoWithinQ,list1,list2]:

GeoWithinQ could be implemented using a combination of GeoNearest and MemberQ:

GeoNearest allows radii to be specified:

This point is just off the coast of Malibu, California:

Possible Issues  (2)

With the default option value "FullyContained"False, GeoWithinQ checks for polygon intersection, which may lead to unexpected results:

GeoWithinQ uses by default the "PrincipalArea" geo variant of a country, which for Spain contains the Canary islands:

Use "FullyContained"True to check for actual containment:

Or use a geo variant that does not include the overlapping region:

GeoWithinQ[entity,loc] uses the polygon available for the given entity, which may not have enough resolution to resolve certain locations correctly, most importantly near the coast:

Therefore this restricted Interpreter call fails:

The polygon for New York does contain this location:

Wolfram Research (2014), GeoWithinQ, Wolfram Language function, https://reference.wolfram.com/language/ref/GeoWithinQ.html (updated 2024).

Text

Wolfram Research (2014), GeoWithinQ, Wolfram Language function, https://reference.wolfram.com/language/ref/GeoWithinQ.html (updated 2024).

CMS

Wolfram Language. 2014. "GeoWithinQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/GeoWithinQ.html.

APA

Wolfram Language. (2014). GeoWithinQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GeoWithinQ.html

BibTeX

@misc{reference.wolfram_2024_geowithinq, author="Wolfram Research", title="{GeoWithinQ}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/GeoWithinQ.html}", note=[Accessed: 21-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_geowithinq, organization={Wolfram Research}, title={GeoWithinQ}, year={2024}, url={https://reference.wolfram.com/language/ref/GeoWithinQ.html}, note=[Accessed: 21-December-2024 ]}