Socket
Socket
Sign inDemoInstall

all-the-cities

Package Overview
Dependencies
4
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    all-the-cities

All the 138,398 cities of the world with a population of at least 1000 inhabitants, in a big JSON array


Version published
Weekly downloads
8.3K
increased by25.36%
Maintainers
1
Install size
6.32 MB
Created
Weekly downloads
 

Readme

Source

all-the-cities

All the 138,398 cities of the world with a population of at least 1000 inhabitants, in a big JSON array that is ready to be imported in MongoDB for geoSpatialSearch.

Derived from the cities-with-1000 npm package, which in turn came from geonames.org data.

Installation

Download node at nodejs.org and install it, if you haven't already.

npm install all-the-cities --save

Usage

const cities = require('all-the-cities');

cities.filter(city => city.name.match('Albuquerque'));

/*
 [{
   cityId: '5454711',
   name: 'Albuquerque',
   country: 'US',
   altCountry: '',
   muni: '',
   muniSub: '',
   featureClass: 'P',
   featureCode: 'PPLA2',
   adminCode: 'NM',
   population: 545852,
   loc: {
     type: 'Point',
     coordinates: [-106.65114, 35.084] 
   }
 }, {
   cityId: '5476960',
   name: 'Los Ranchos de Albuquerque',
   country: 'US',
   altCountry: '',
   muni: '',
   muniSub: '',
   featureClass: 'P',
   featureCode: 'PPL',
   adminCode: 'NM',
   population: 6024,
   loc: {
     type: 'Point',
     coordinates: [-106.6428, 35.16199]
   }
 }]
*/

Fields available to import


id - Id of the city (same in openWeatherMap)
name
altName
country
featureCode
adminCode
population
loc: { type: 'Point', coordinates: [0, 0] }

for **GEO JSON data**, a particular format is needed in MongoDB Schema as written in loc field above

Tests

npm install
npm test

Dependencies

None

Dev Dependencies

  • cities-with-1000: lat/lon, names of cities with over 1000 people
  • tape: tap-producing test harness for node and browsers
  • split2: split a Text Stream into a Line Stream, using Stream 3
  • through2: A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise

License

MIT

Keywords

FAQs

Last updated on 18 Mar 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc