2.0.0 • Published 1 year ago

geocountries v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

logo

npm jsdeliver license code size

A tool to get ISO codes and geometries from country names

Installation

In browser

<script src="https://cdn.jsdelivr.net/npm/geocountries@2" charset="utf-8"></script>

In Observable

geocountries = require("geocountries@2")

Documentation

Domumentation and running examples available here.

Features

getcode

To get an ISO3 code from a country name.

geocountries.getcode("United States of America")

returns an object

{name: "United States of America", iso3: "USA", score: 1}

view

To visualize the matching of codes and names.

geocountries.view({
  json: mydata, // a geojson
  name: "name", // filed with country names
  threshold: 0.9, // level of similarity
})

returns a svg chart

npm.io

add

If you know your dataset well and you don't need to investigate it, you can skip all the previous steps and add directly the iso3 codes.

geocountries.add({
  json: mydata, // a geojson
  name: "name",  // filed with country names
  threshold: 0.9, // level of similarity
})

returns a new json with ISO3 codes and scores

Patches

Note tha you can add a patch to add or remove codes.

geocountries.add({
  json: mydata, // a geojson
  name: "name",  // filed with country names
  threshold: 0.9, // level of similarity
  patch: [
    { name: "French Polynesia", iso3: "PYF" },
    { name: "Niue", iso3: "NIU" },
    { name: "Cook Islands", iso3: "COK" },
    { name: "China, Macao SAR", iso3: "MAC" },
    { name: "Southern Africa", iso3: undefined },
    { name: "South America", iso3: undefined }
  ]
})

Duplicate

A simple function to get duplicate codes

geocountries.duplicate({ json: data, field: "name" })
1.2.0

1 year ago

2.0.0

1 year ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

0.0.1

2 years ago