world-cities-json
An NPM module that contains a JSON array of world cities sourced from the SimpleMaps World Cities Database, created by the team at Jet Set Expert.
Features
- JSON array of world cities with the following fields:
- city: The name of the city/town as a Unicode string (e.g. Goiânia).
- city_ascii: city as an ASCII string (e.g. Goiania).
- lat: The latitude of the city/town.
- lng: The longitude of the city/town.
- country: The name of the city/town's country.
- iso2: The alpha-2 iso code of the country.
- iso3: The alpha-3 iso code of the country.
- admin_name: The name of the highest level administration region of the city/town (e.g. a US state or Canadian province).
Sample JSON
[
{
"city": "Tokyo",
"city_ascii": "Tokyo",
"lat": "35.6897",
"lng": "139.6922",
"country": "Japan",
"iso2": "JP",
"iso3": "JPN",
"admin_name": "Tōkyō",
"capital": "primary",
"population": "37732000",
"id": "1392685764"
},
{
"city": "Jakarta",
"city_ascii": "Jakarta",
"lat": "-6.1750",
"lng": "106.8275",
"country": "Indonesia",
"iso2": "ID",
"iso3": "IDN",
"admin_name": "Jakarta",
"capital": "primary",
"population": "33756000",
"id": "1360771077"
},
...
Installation
npm install cities-json
Usage
const { cities } = require("cities-json");
console.log(cities);
Generating the cities.json file
To generate the cities.json file from a source CSV file, follow these steps:
- Download the desired CSV file from the SimpleMaps World Cities Database.
- Place the CSV file in the /data directory and name it "worldcities.csv" or use the --source command line option to provide a custom path.
- Run the generate.js script:
node src/generate.js [--source path/to/your/csv]
Source and License
Data is sourced from the SimpleMaps World Cities Database and is licensed under the Creative Commons Attribution 4.0 International (CC BY 4.0) license.
Links & Resources
Jet Set Expert
cities-json on GitHub
world-cities-json on NPM
world-cities-json on Aliyun
world-cities-json on TAONPM
world-cities-json on jsDlivr
world-cities-json on Snyk
world-cities-json on Libraries.io
world-cities-json on RunKit
world-cities-json on npm trends
world-cities-json on Package Phobia
world-cities-json on Skypack
world-cities-json on CNPM
world-cities-json on githubmemory
world-cities-json on npm.io
world-cities-json on Pkg Stats
Related Packages
airports-json on GitHub
airports-json on NPM