data:
- plane routes: origin, destination airports (lat, lng) - only direct flights
- data: timezone changes on route (origin and destination timezones, airport identification data (name, airport code)
data munging steps:
- add field names to both csvs from source
- initialize your folder, initialize package.json (
npm init
) - set up node script with required modules
- fs (included, 'file system')
var fs = require('fs')
- path (included, utility functions for creating paths) (
path.join(__dirname, 'path/to/file')
) - arc (not included, https://github.com/springmeyer/arc.js/,
npm install --save arc
) - csv-parse (not included, http://csv.adaltas.com/parse/)
- fs (included, 'file system')
- write some tests - tape tutorial
- file(s) you need to read exist
- read in airport file
- transform it into an object
var airports = {
SFO: {
coordinates: [lng, lat],
timezone: UTC-8
},
DCA : {...}
};
- read in route file
- create geojson (FeatureCollection of LineStrings)
- iterate through the routes file
- use arc.js to generate the linestrings into geojson
- populate each linestring's properties with the info you need
- write geojson to a new file (
fs.writeFile()
)
fs.readFile('file1', function(err, data){
fs.readFile('file2', function( err2, data2){
// now you have access to both files' data
})
})