Use https://www.npmjs.com/package/geojson-places instead.
This module takes a latitude and longitude and determine the country where it is contained.
npm install --save country-geolocalizer
npm run test
Get country from the following latitude/longitude (Madrid):
const result = getCountry(40.4167047, -3.7035825);
console.log(result);
// {
// ADMIN: 'Spain',
// ISO_A3: 'ESP'
// }
Get null from a latitude/longitude in the middle of the sea:
const result = getCountry(0.0, 0.0);
console.log(result);
// null
-
GeoJSON with all country polygons extracted from https://datahub.io/core/geo-countries
-
Checks if a point is contained in a polygon (based on the Jordan curve theorem), for more info: http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html