GithubHelp home page GithubHelp logo

isabella232 / osrm-isochrone Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mapbox/osrm-isochrone

0.0 0.0 0.0 34 KB

Generate drivetime isochrones from OpenStreetMap data using OSRM

License: MIT License

JavaScript 64.07% Makefile 35.93%

osrm-isochrone's Introduction

osrm-isochrone

Warning: this is experimental

Build Status

Generate drive-time isochrones from OpenStreetMap data using OSRM.

##Install

npm install osrm-isochrone

##Build An osrm file is required for routing. This can be generated using included binaries. (Note: this will take a lot of processing power if you are planning to use the entire planet.osm file, for general use a regional OSM data extract is preferable. More info here)

#first download an osm file containing the area you need
./node_modules/osrm-isochrone/osrm/lib/binding/osrm-extract mydata.osm -p ./node_modules/osrm-isochrone/osrm/test/data/car.lua
./node_modules/osrm-isochrone/osrm/lib/binding/osrm-prepare mydata.osrm -p ./node_modules/osrm-isochrone/osrm/test/data/car.lua

##Usage Create a file containing something such as:

var isochrone = require('osrm-isochrone');

var time = 300; // 300 second drivetime (5 minutes)
var location = [-77.02926635742188,38.90011780426885]; // center point
    // Note: coordinates are E/W , N/S
var options = {
  resolution: 25, // sample resolution
  maxspeed: 70, // in 'unit'/hour
  unit: 'miles', // 'miles' or 'kilometers'
  network: './dc.osrm' // prebuilt dc osrm network file, or use the one just built.
}

isochrone(location, time, options, function(err, drivetime) {
  if(err) throw err;
  // a geojson linestring
  console.log(JSON.stringify(drivetime))
});

Run with

node my-file.js

The output will be in GeoJSON format.

###Advanced Alternatively the network parameter can be an OSRM module instance. Allowing setup an OSRM with custom parameters, e.g. usage of shared-memory.

You can too define your own function to draw line/polygon instead of default:

var concave = require('turf-concave');
var Isochrone = require('osrm-isochrone');

var time = 300; // 300 second drivetime (5 minutes)
var location = [-77.02926635742188,38.90011780426885]; // center point
var options = {
  resolution: 25, // sample resolution
  maxspeed: 70, // in 'unit'/hour
  unit: 'miles', // 'miles' or 'kilometers'
  network: './dc.osrm' // prebuild dc osrm network file
}

var isochrone = new Isochrone(location, time, options, function(err, drivetime) {
  if(err) throw err;
  // your geojson from draw overload
  console.log(JSON.stringify(drivetime))
});
isochrone.draw = function(destinations) {
  var inside = destinations.features.filter(function(feat) {
    return feat.properties.eta <= time;
  });
  destinations.features = inside;
  return concave(destinations, this.sizeCellGrid, unit);
}
isochrone.getIsochrone();

osrm-isochrone's People

Contributors

divingdeer avatar fab-girard avatar frodrigo avatar morganherlocker avatar paco-valdez avatar themarex avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.