coordinate_to_country

1.1.0 • Public • Published

#coordinate_to_country

This is a fork of country-iso with some bugfixes and additional features:

  • Enclaves and exclaves are now handled properly: the dataset used by country-iso doesn't handle polygons with holes in them, resulting in weird outputs such as the entirety of Lesotho being shown as a part of South Africa.
  • ISO 3166 alpha-2 codes are now also optionally supported.

Both of these are accomplished thanks to a new dataset I generated, @osm_borders/maritime_10m. Just like its predecessor, it originates from high-quality OpenStreetMap data, but with fixes for the aforementioned issues. For more details, see the osm_borders Github page.

Installation and usage

This library can be installed using npm install coordinate_to_country

Querying a lat, lng pair is simple, with all queries returning an array of the countries which claim sovereignty over a given territory:

	const lookup = require("coordinate_to_country");
	lookup(53.218620, 6.567365); // => ["NLD"]

You can also request the alpha-2 version of the ISO-3166 by passing the optional isoA2 = true parameter:

	lookup(53.218620, 6.567365, true); // => ["NL"]

Disputed territories and coordinates not inside any country also work:

	lookup(0, 0); // => []
	lookup(45.739518, 18.953996); // => ["SRB", "HRV"]

Licence

This project is licensed under the MIT License.

This library was created by Emily Nagy (itisem) based on country-iso by Simone Primarosa (simonepri).

Package Sidebar

Install

npm i coordinate_to_country

Weekly Downloads

732

Version

1.1.0

License

MIT

Unpacked Size

4.24 kB

Total Files

4

Last publish

Collaborators

  • itisem