This repository is part of the Pelias project. Pelias is an open-source, open-data geocoder originally sponsored by Mapzen. Our official user documentation is here.
This repository is part of the Pelias project. Pelias is an open-source, open-data geocoder built by Mapzen that also powers Mapzen Search. Our official user documentation is here.
pelias-whosonfirst is a tool used for importing Who's On First data from local files into a Pelias ElasticSearch store.
Node.js 6 or newer (the latest in the 8 series is currently recommended).
There are two major categories of Who's on First data supported: hierarchy (or admin) data, and venues.
Hierarchy data represents things like cities, countries, counties, boroughs, etc.
Venues represent individual places like the Statue of Liberty, a gas station, etc. Venues are subdivided by country, and sometimes regions within a country.
Currently, the supported hierarchy types are:
- borough
- continent
- country
- county
- dependency
- disputed
- empire
- localadmin
- locality
- macrocounty
- macrohood
- macroregion
- marinearea
- neighbourhood
- ocean
- region
- postalcodes (optional, see configuration)
Other types may be included in the future.
This page has a description of all the types supported by Who's on First.
This importer is configured using the pelias-config
module.
The following configuration options are supported by this importer.
key | required | default | description |
---|---|---|---|
imports.whosonfirst.datapath |
yes | full path to where Who's on First data is located (note: the included downloader script will automatically place the WOF data here, and is the recommended way to obtain WOF data) | |
imports.whosonfirst.importPostalcodes |
no | false | set to true to include postalcodes in the data download and import process |
imports.whosonfirst.importVenues |
no | false | set to true to include venues in the data download and import process |
imports.whosonfirst.importPlace |
no | set to a WOF id (number or string) indicating the region of interest, only data pertaining to that place shall be downloaded. Use the WOF spelunker tool search for an ID of a place. | |
imports.whosonfirst.missingFilesAreFatal |
no | false | set to true for missing files from Who's on First bundles to stop the import process |
- The
download
script will download the required bundles/sqlite databases and place the data into the datapath configured in pelias-config in the required directory layout. To install the required node module dependencies and run the download script:
npm install
npm run download
## or
npm run download -- --admin-only # to only download hierarchy data, without venues or postalcodes
When running an instance intended to provide coverage for an area smaller than the entire world,
it is recommended that the importPlace
config parameter is used to limit the data download to records
that are parents or descendants of the specified place. See the configuration details in the above section of this document.
We currently only support a single ID at a time. If multiple places need to be downloaded, the script can be executed multiple times;
one for each desired place.
Warning: It is recommended to only use the download filtering option for places more granular than country
.
The filtering script is intended for small areas and so has not been tested fully for large ones.
Warning: Who's on First data is big. Just the hierarchy data is tens of GB, and the full dataset is over 100GB on disk.
Additionally, Who's on First uses one file per record. In addition to lots of disk space,
you need lots of free inodes. On
Linux/Mac, df -ih
can show you how many free inodes you have.
Expect to use a few million inodes for Who's on First. You probably don't want to store multiple copies of the Who's on First data due to its disk requirements.
To install the required node module dependencies and execute the importer, run:
$> npm install
$> npm start
This project exposes a number of node streams for dealing with Who's on First data and metadata files:
metadataStream
: streams rows from a Who's on First metadata fileparseMetaFiles
: CSV parse stream configured for metadata file contentsloadJSON
: parallel stream that asynchronously loads GeoJSON filesrecordHasIdAndProperties
: rejects Who's on First records missing id or propertiesisActiveRecord
: rejects records that are superseded, deprecated, or otherwise inactiveisNotNullIslandRelated
: rejects Null Island and other records that intersect it (currently just postal codes at 0/0)recordHasName
: rejects records without namesconformsTo
: filter Who's on First records on a predicate (see lodash's conformsTo for more information)