GeoNearest

GeoNearest[enttype,loc]

returns the geographic entity of type enttype closest to the geo location loc.

GeoNearest[{reg1,reg2,,regn},loc]

returns the nearest of the regi.

GeoNearest[{reg1val1,reg2val2,,regnvaln},loc]

returns the vali corresponding to the nearest regi.

GeoNearest[{reg1,reg2,,regn}{val1,val2,,valn},loc]

returns the same result.

GeoNearest[{reg1,reg2,,regn}Automatic,loc]

takes the vali to be successive integers i.

GeoNearest[spec,loc,n]

returns n nearest values.

GeoNearest[spec,loc,{n,r}]

returns up to n matches within a radius r of loc.

Details and Options

  • In GeoNearest[enttype,loc], enttype can be specified as an Entity object, such as Entity["Country"], or as a string, such as "City".
  • Valid forms of enttype include:
  • "AdministrativeDivision"administrative division of any level
    "AdministrativeDivision1"first-level administrative division
    "AdministrativeDivision2"second-level administrative division
    "AdministrativeDivision3"third-level administrative division
    "Airport"airports
    "Bridge"bridges
    "Building"buildings
    "City"city
    "Country"country, territory, etc.
    "HistoricalCountry"historical countries, regions, empires, etc.
    "MilitaryConflict"military conflicts
    "Mountain"mountains
    "Ocean"oceans
    "USCounty"US counties
    "USState"US states
    "Volcano"volcanoes
    "ZIPCode"US ZIP codes
    Dated[ent,date]entities of type enttype in date
    Except[ent,enttype]entities other than ent of type enttype
    GeoVariant[enttype,variant]entities using variant regions
    EntityClass["type","class"]individual members of class
    type1|type2|any of the typei
    Allany possible type
  • In GeoNearest[enttype,loc], loc can be any geo location object, including GeoPosition objects; geo entities of domains such as "City", "Country" or "HistoricalCountry"; Dated[] objects; GeoVariant[] expressions; and more.
  • Geographic regions can be specified as geo locations, an Entity or EntityClass object or a GeoGraphics primitive.
  • For domains of time-dependent entities, GeoNearest by default returns results corresponding to the moment of closest approach to the given location, which may itself also be time dependent.
  • A radius should be given as a Quantity object or the number 0.
  • GeoNearest[spec,loc,{All,r}] returns all results within radius r of loc.
  • GeoNearest always returns a list. If there are multiple nearest matches, GeoNearest[spec,loc] will return all of them.
  • GeoNearest[spec,loc,{n,r}] may return an empty list if there are no matches within the specified radius.
  • The following options can be given:
  • DistanceFunction "Boundary"how to compute distances for extended regions
    TimeConstraint30how many seconds to allow for computation
  • The following possible settings can be given for DistanceFunction:
  • "Boundary"minimum distance between any points in regions
    "Center"distance between centers of regions
    "SignedBoundary"distance to boundary, negative for interior points

Examples

open allclose all

Basic Examples  (3)

Find your current or nearest country:

The country closest to the center of the Atlantic Ocean:

The five counties nearest to Chicago, Illinois, United States:

All volcanoes within a radius of 1000 miles from London:

Scope  (16)

Entity Types  (6)

The three countries closest to Australia:

Entity types can also be specified with Entity head:

Give countries whose closest point to Germany is closer than 100 kilometers:

Find entities that cover a particular point:

Return famous buildings within one of those extended regions:

The mountain or volcano closest to your location:

The US state other than California closest to San Francisco:

The country whose center is closest to Paris:

With the default variant "PrincipalArea", Paris is at zero distance from France:

Groups of Entities and Regions  (6)

The border of the continental United States to which the city of Saint Louis, Missouri, is closest:

Return the value corresponding to the border entity closest to Denver, Colorado:

An equivalent syntax:

The closest of several points to your current location:

The position in a list of the point closest to Chicago:

Using explicit labels:

Determine whether Germany is closest to a member of OPEC, the Baltic states or the British Commonwealth:

Determine to which of the following city pairs Greece is closest:

Historical Entities  (4)

GeoNearest with historical entities returns the closest entities that correspond to the same time period:

Use Dated with historical entities to specify a particular date or interval of dates:

Using Dated in the first argument gives results indicating the time of closest approach:

With a non-historical location, the search is performed geographically, regardless of dates:

Specifying date information for the location will give results that correspond to those dates:

Check that the dates correspond to years between 1750 and 1800:

Options  (1)

DistanceFunction  (1)

By default, distances are measured from the boundaries of extended regions:

With DistanceFunction->"Center", distance from the center of the entity is used:

Applications  (1)

Find the countries that fall at least in part within a given latitude/longitude region:

Plot them, together with the latitude/longitude region:

Properties & Relations  (2)

GeoIdentify is a specialized form of GeoNearest:

GeoNearest includes all entities, if any, at zero distance from an extended region:

GeoEntities only includes entities that overlap the region:

Neat Examples  (1)

Construct a function to find the shortest route from a given position to the nearest foreign country:

Compute the shortest path out of the country in which you are:

Make a map showing the shortest path:

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

Text

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

CMS

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

APA

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

BibTeX

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

BibLaTeX

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