Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonepri/country-iso
🗺 Get the ISO 3166-1 alpha-3 country code from geographic coordinates.
https://github.com/simonepri/country-iso
country-iso geojson maps nodejs
Last synced: 3 days ago
JSON representation
🗺 Get the ISO 3166-1 alpha-3 country code from geographic coordinates.
- Host: GitHub
- URL: https://github.com/simonepri/country-iso
- Owner: simonepri
- License: mit
- Created: 2017-09-04T12:55:38.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-08T13:30:05.000Z (almost 7 years ago)
- Last Synced: 2024-11-07T06:11:47.826Z (11 days ago)
- Topics: country-iso, geojson, maps, nodejs
- Language: JavaScript
- Homepage:
- Size: 12.3 MB
- Stars: 144
- Watchers: 7
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# country-iso
[![Travis CI](https://travis-ci.org/simonepri/country-iso.svg?branch=master)](https://travis-ci.org/simonepri/country-iso) [![Codecov](https://img.shields.io/codecov/c/github/simonepri/country-iso/master.svg)](https://codecov.io/gh/simonepri/country-iso) [![npm](https://img.shields.io/npm/dm/country-iso.svg)](https://www.npmjs.com/package/country-iso) [![npm version](https://img.shields.io/npm/v/country-iso.svg)](https://www.npmjs.com/package/country-iso) [![npm dependencies](https://david-dm.org/simonepri/country-iso.svg)](https://david-dm.org/simonepri/country-iso) [![npm dev dependencies](https://david-dm.org/simonepri/country-iso/dev-status.svg)](https://david-dm.org/simonepri/country-iso#info=devDependencies)
> 🗺 Get ISO 3166-1 alpha-3 country code from geographic coordinates.Click on the map to see a live preview.
## Synopsis
Given the latitude and longitude coordinates this package returns the country code of the country in which the coordinates fall into.The package internally uses [@geo-maps/countries-maritime](https://github.com/simonepri/geo-maps/blob/master/info/countries-maritime.md) map with 10m resolution to give you the right country code.
The accuracy of the map has been tested with [23785 cities](fixtures/cities.geo.json) but the [demo](http://simonepri.github.io/country-iso/) allows you to actually test it manually by just clicking on the map to see what it returns.Do you believe that this is useful? If so, support us with a ⭐️!
## Install
```bash
$ npm install --save country-iso
```## Usage
You can query any `(lat,lng)` pair on the earth. It also works for territorial waters and disputed countries.```javascript
const countryIso = require('country-iso');// Query a point in Italy.
countryIso.get(41.9028, 12.4964);
// => ['ITA']// Query a disputed country.
countryIso.get(24, -14);
// => ['ESH', 'MAR']// Query a point somewhere in Atlantic Ocean.
countryIso.get(40, -40);
// => []
```## API
## get(lat, lng) ⇒Array.<string>
Searches for every country which contains the point (lat, lng).**Returns**:
Array.<string>
- Array of ISO 3166 alpha-3 country code for the geographic
coordinates.| Param | Type | Description |
| --- | --- | --- |
| lat |number
| The latitude of the point. |
| lng |number
| The longitude of the point. |## Related
* [is-sea](https://github.com/simonepri/is-sea): 🌊 Check whether a geographic coordinate is in the sea or not on the earth.## Authors
* **Matteo Chen** - [chq-matteo](https://github.com/chq-matteo)
* **Simone Primarosa** - [simonepri](https://github.com/simonepri)See also the list of [contributors](https://github.com/simonepri/country-iso/contributors) who participated in this project.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.