Created
July 4, 2015 11:03
-
-
Save fentas/1ddb7946983255628bba to your computer and use it in GitHub Desktop.
Download and output airport database as geojson (openflights.org)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var got = require('got'), | |
csv = require('csv-parser'), | |
through = require('through2'), | |
geojsonStream = require('geojson-stream'); | |
/** | |
* Download and output airport database | |
* | |
* http://openflights.org/data.html#airport | |
*/ | |
got('https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat') | |
.pipe(csv({ | |
headers: [ | |
'id', | |
'name', | |
'city', | |
'country', | |
'faa', | |
'icao', | |
'lat', | |
'lng', | |
'alt', | |
'tz-offset', | |
'dst', | |
'tz' | |
] | |
})) | |
.pipe(through.obj(function(row, enc, cb) { | |
this.push({ | |
type: 'Feature', | |
properties: row, | |
geometry: { | |
type: 'Point', | |
coordinates: [ | |
parseFloat(row.lng), | |
parseFloat(row.lat) | |
] | |
} | |
}); | |
cb(); | |
})) | |
.pipe(geojsonStream.stringify()) | |
.pipe(process.stdout); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated version of https://www.npmjs.com/package/openflights-geojson