Skip to content

A tool to get ISO codes and geometries from country names

License

Notifications You must be signed in to change notification settings

riatelab/geocountries

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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" })

About

A tool to get ISO codes and geometries from country names

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published