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 either an Entity object or an extended GeoGraphics primitive. The location loc can additionally be specified as a GeoPosition or related point-like location object.
  • 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  (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:

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 2017).

Text

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

BibTeX

@misc{reference.wolfram_2020_geowithinq, author="Wolfram Research", title="{GeoWithinQ}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/GeoWithinQ.html}", note=[Accessed: 26-January-2021 ]}

BibLaTeX

@online{reference.wolfram_2020_geowithinq, organization={Wolfram Research}, title={GeoWithinQ}, year={2017}, url={https://reference.wolfram.com/language/ref/GeoWithinQ.html}, note=[Accessed: 26-January-2021 ]}

CMS

Wolfram Language. 2014. "GeoWithinQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. 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