Skip to content

Instantly share code, notes, and snippets.

@mollymerp
Last active October 6, 2016 19:23
Show Gist options
  • Save mollymerp/224c707d5dbe3950203036030cb7777d to your computer and use it in GitHub Desktop.
Save mollymerp/224c707d5dbe3950203036030cb7777d to your computer and use it in GitHub Desktop.

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
  • 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
  })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment