Skip to content

codeforamerica/DemoDexter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About DemoDexter

DemoDexter uses a node.js server and a neo4j graph database to build a street network from OpenStreetMap data.

Visiting a street's page shows you all named streets which are connected to it.

Neo4j network view:

Neo4j, a graph database

Collecting statistics on a neighborhood level for every point in a large dataset becomes much simpler using a graph database.

DemoDexter stores tagged items (like BART stations and Chipotle restaurants) as Points, and links them to Streets. Then Streets are linked to any connecting Streets. This allows us to collect information on a network / neighborhood level. It also lets us count links between any street in the city and the nearest BART station or similar target.

San Francisco: an Open Network API and Datastore

Experimental project. Here's how to get started with the API:

  • /tags - add a new tag, see existing tags

  • /tagname/YOUR_TAG - see a map and tag additional streets

  • /embed/YOUR_TAG - draws a map of tagged streets and connecting streets

  • /count/STREETNAME/YOUR_TAG - counts tags on the street

  • /networkcount/STREETNAME/YOUR_TAG - counts tags on connecting streets (and not including the street itself)

  • /access/YOUR_TAG - returns Carto which color-codes your streets by access to the nearest tag

  • /choice/YOUR_TAG - returns Carto which color-codes your streets by access to the two nearest tags

You can put Carto into TileMill to draw pretty maps.

Oakland: adding a city

Oaklandexter is an Oakland / Alameda County version of DemoDexter.

With the right Python script, you can import streets from any .OSM file. This is a library access map produced on Oaklandexter.

Macon: Demolition Data

These features were available only on the Macon instance of DemoDexter.

/demolished searches for demolished houses on a street:

var params = {
    streetId: req.query['id'] * 1,
    status: "Demolished & Cleared"
};
var query = [
    'START points=node:nodes(type="point"), street=node({streetId})',
    'MATCH (points) -[:partof]-> (street)',
    'WHERE points.action = {status}',
    'RETURN points'
].join('\n');

/network returns the demolished houses on streets connected to your street:

var params = {
    streetId: req.query['id'] * 1,
    status: "Demolished & Cleared"
};
var query = [
    'START points=node:nodes(type="point"), street=node({streetId})',
    'MATCH (points) -[:partof]-> (neighborstreet) -[:connectsto]-> (street)',
    'WHERE points.action = {status}',
    'RETURN points'
].join('\n');

Building the street network

Locally

  • Download a .OSM file from metro.teczno.com
  • Start your neo4j database:
    neo4j-community-1.8/bin/neo4j start
    
  • Start the DemoDexter server:
    npm start
    
  • Edit and run the storeosm.py script (included in repo) to add and connect streets from the .osm file to your database. This can take a few hours.
  • If your upload is interrupted, delete the last street and set firstToAdd eqaul to the street name (lowercase, no spaces)

Cloud process through Heroku

  • Follow the installation directions for Heroku and install the neo4j addon
  • Include your .osm file and a modified storeosm.py file and submit them to the repo
  • Run storeosm.py using heroku run:detached 'python storeosm.py'
  • Use 'heroku logs' to check the status of your script
  • Once you have finished adding streets, make a commit to remove the script and OSM file

About Node-Neo4j Template

Node-Neo4j Template from aseemk simplifies the use of Neo4j from Node.js. It uses the node-neo4j library, available on npm as neo4j.

The app introduces you to Neo4j with a social network manager: it lets you add and remove users and "follows" relationships between them.

Installation

# Install the required dependencies
npm install

# Install Neo4j 1.8 locally
curl "http://dist.neo4j.org/neo4j-community-1.8-unix.tar.gz" --O "db-unix.tar.gz"
tar -zxvf db-unix.tar.gz 2> /dev/null
rm db-unix.tar.gz

Usage

# Start the local Neo4j instance
neo4j-community-1.8/bin/neo4j start

# Run the app!
npm start

The app will now be accessible at http://localhost:3000/.

Uploading to Heroku

Both node-neo4j template and DemoDexter support deploying to Heroku.

Create the app and add a neo4j 1.8 addon

heroku create APP_NAME
heroku addons:add neo4j --neo4j-version 1.8
git push heroku master

Miscellany

  • MIT license.

About

Collect stats and make maps on a neighborhood level using a network database, OpenStreetMap, & city records

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published