Neo4j
                 Spatial
                 GIS for the rest of us


                                          #neo4j
Peter Neubauer                            @peterneubauer
                                          peter@neotechnology.com
Neo Technology
NOSQL data models
            Key-value stores
Data size




                          Bigtable clones


                                            Document
                                            databases


                                                           Graph databases




                                                        Data complexity
The Neo4j model: Property Graph
 Core abstractions:
                                              name = “Emil”

   Nodes
                                              age = 29
                                              sex = “yes”


   Relationships between nodes
   Properties on both                     1                         2



                         type = KNOWS
                         time = 4 years                       3

                                                                  type = car
                                                                  vendor = “SAAB”
                                                                  model = “95 Aero”
Neo4j – Nodes, Relationships, Properties




 Nodes have different properties
   Matrix characters: People vs. Programs
 Build structure as you go
    Who loves Neo?
Building a node space
GraphDatabaseService graphDb = ... // Get factory


// Create Thomas 'Neo' Anderson
Node mrAnderson = graphDb.createNode();
mrAnderson.setProperty( "name", "Thomas Anderson" );
mrAnderson.setProperty( "age", 29 );

// Create Morpheus
Node morpheus = graphDb.createNode();
morpheus.setProperty( "name", "Morpheus" );
morpheus.setProperty( "rank", "Captain" );
morpheus.setProperty( "occupation", "Total bad ass" );

// Create a relationship representing that they know each other
mrAnderson.createRelationshipTo( morpheus, RelTypes.KNOWS );
// ...create Trinity, Cypher, Agent Smith, Architect similarly
Building a node space
GraphDatabaseService graphDb = ... // Get factory
Transaction tx = graphdb.beginTx();

// Create Thomas 'Neo' Anderson
Node mrAnderson = graphDb.createNode();
mrAnderson.setProperty( "name", "Thomas Anderson" );
mrAnderson.setProperty( "age", 29 );

// Create Morpheus
Node morpheus = graphDb.createNode();
morpheus.setProperty( "name", "Morpheus" );
morpheus.setProperty( "rank", "Captain" );
morpheus.setProperty( "occupation", "Total bad ass" );

// Create a relationship representing that they know each other
mrAnderson.createRelationshipTo( morpheus, RelTypes.KNOWS );
// ...create Trinity, Cypher, Agent Smith, Architect similarly
tx.commit();
Code (2): Traversing a node space
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
   Traverser.Order.BREADTH_FIRST,
   StopEvaluator.END_OF_GRAPH,
   ReturnableEvaluator.ALL_BUT_START_NODE,
   RelTypes.KNOWS,
   Direction.OUTGOING );

// Traverse the node space and print out the result
System.out.println( "Mr Anderson's friends:" );
for ( Node friend : friendsTraverser )
{
   System.out.printf( "At depth %d => %s%n",
       friendsTraverser.currentPosition().getDepth(),
       friend.getProperty( "name" ) );
}
Ruby
gem install neo4j

require ”rubygems”
require 'neo4j'

class Person
  include Neo4j::NodeMixin
  property :name, :age, :occupation
  index :name
  has_n :friends
end

Neo4j::Transactoin.run do
  neo = Person.new :name=>'Neo', :age=>29
  morpheus = Person.new :name=>'Morpheus', :occupation=>'badass'
  neo.friends << morpheus
end

neo.friends.each {|p|...}
Routing
Social graphs
Impact, Dependency Analysis
Master Data Management
Why Spatial?
  Complex data
    Multiple indexing (domain, Spatial, temporal)
  Location entering many domains
  GIS going mainstream, topologies explode
  No good systems out there
  Proprietary stacks rule (ESRI, Oracle)
  Open Government Data
  Shapefiles suck.
Persistence backends in GIS
  Shapefiles
  PostGIS
  MySQL
  Oracle Spatial
  ESRI
  GeoCouch
  Cassandra (?)
  Neo4j Spatial
Current challenges in Spatial
  Domain and Spatial interconnections
  Unstructured domain data
  Routing
  Topology handling
  No good OSS full GIS stack
The Neo4j Spatial stack
     OpenLayers                       PHP
                        AJAX
       WMS              Editing        JS
       WMF                             C#
                                                      Rails
                                            Spring   Django
                                             Roo




     GeoServer uDig    GeoMaya      REST    Java     Scripting


                  GeoTools

                    Neo4j Spatial


                              Neo4j
OpenStreetMap
The OpenStreetMap dataset
 Wiki for Spatial info
 Freely available data
 Very unstructured, free tagging
   Points, Ways, Relations, Tags, Changesets
 Changes can be pushed back
   Used for other purposes
 Great coverage in interesting places (towns, disasters etc)
OpenStreetMap
OpenStreetMap
GSoC 2010

 Davide Savazzi
 Geotools & GeoServer
 Routing
 uDig
Connecting and Splitting

  Layer1                   Layer1


  Layer2                   Layer2


  Layer3                   Layer3




 Why have layers at all?
    Simpler renderers
    Historical
    Data sources
GSoC 2010 - Routing
Connecting and Splitting


 Routing




 OSM Dynamic Layers
GSoC 2010 - uDig
Neo4j dynamic layers

                         Geometry                     Layer1
                         Encoder
                          Dynamic
                           Query                      Layer2

                          Dynamic
                           Styles
                                                      Layer3
                          Dynamic
                          Meta-Inf


Connected domain data   Neo4j Spatial   GIS and Spatial stacks
OpenStreetMap




Dynamic                 OSM
 Laye rs




     Inde x (RTre e )
Dynamic Layers
Dynamic Layers
Dynamic Layers
Future
  Complex spatial mapping and analytics made easy
  Editing
    Fine Grained Geotools Feature Editing
    OSM Editor
  OSM
    Caching sub-graphs (desktop & mobile)
    More Dynamic Layers & Shapefile export
  Topology
    Persist all topological results in graph
  Benchmarking & Performance
     Improved indexing
     Composite index
API References
 Wiki, Code, API references
   http://wiki.neo4j.org/content/Neo4j_Spatial
   http://github.com/neo4j/neo4j-spatial
   http://components.neo4j.org/neo4j-spatial
   Mailing list: neo4j@lists.neo4j.org
   http://neo4j.org/community/list/
Questions?




             Image credit: lost again! Sorry :(
http://neotechnology.com

Neo4j spatial-nosql-frankfurt

  • 1.
    Neo4j Spatial GIS for the rest of us #neo4j Peter Neubauer @peterneubauer peter@neotechnology.com Neo Technology
  • 2.
    NOSQL data models Key-value stores Data size Bigtable clones Document databases Graph databases Data complexity
  • 3.
    The Neo4j model:Property Graph Core abstractions: name = “Emil” Nodes age = 29 sex = “yes” Relationships between nodes Properties on both 1 2 type = KNOWS time = 4 years 3 type = car vendor = “SAAB” model = “95 Aero”
  • 4.
    Neo4j – Nodes,Relationships, Properties Nodes have different properties Matrix characters: People vs. Programs Build structure as you go Who loves Neo?
  • 5.
    Building a nodespace GraphDatabaseService graphDb = ... // Get factory // Create Thomas 'Neo' Anderson Node mrAnderson = graphDb.createNode(); mrAnderson.setProperty( "name", "Thomas Anderson" ); mrAnderson.setProperty( "age", 29 ); // Create Morpheus Node morpheus = graphDb.createNode(); morpheus.setProperty( "name", "Morpheus" ); morpheus.setProperty( "rank", "Captain" ); morpheus.setProperty( "occupation", "Total bad ass" ); // Create a relationship representing that they know each other mrAnderson.createRelationshipTo( morpheus, RelTypes.KNOWS ); // ...create Trinity, Cypher, Agent Smith, Architect similarly
  • 6.
    Building a nodespace GraphDatabaseService graphDb = ... // Get factory Transaction tx = graphdb.beginTx(); // Create Thomas 'Neo' Anderson Node mrAnderson = graphDb.createNode(); mrAnderson.setProperty( "name", "Thomas Anderson" ); mrAnderson.setProperty( "age", 29 ); // Create Morpheus Node morpheus = graphDb.createNode(); morpheus.setProperty( "name", "Morpheus" ); morpheus.setProperty( "rank", "Captain" ); morpheus.setProperty( "occupation", "Total bad ass" ); // Create a relationship representing that they know each other mrAnderson.createRelationshipTo( morpheus, RelTypes.KNOWS ); // ...create Trinity, Cypher, Agent Smith, Architect similarly tx.commit();
  • 7.
    Code (2): Traversinga node space // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL_BUT_START_NODE, RelTypes.KNOWS, Direction.OUTGOING ); // Traverse the node space and print out the result System.out.println( "Mr Anderson's friends:" ); for ( Node friend : friendsTraverser ) { System.out.printf( "At depth %d => %s%n", friendsTraverser.currentPosition().getDepth(), friend.getProperty( "name" ) ); }
  • 8.
    Ruby gem install neo4j require”rubygems” require 'neo4j' class Person include Neo4j::NodeMixin property :name, :age, :occupation index :name has_n :friends end Neo4j::Transactoin.run do neo = Person.new :name=>'Neo', :age=>29 morpheus = Person.new :name=>'Morpheus', :occupation=>'badass' neo.friends << morpheus end neo.friends.each {|p|...}
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
    Why Spatial? Complex data Multiple indexing (domain, Spatial, temporal) Location entering many domains GIS going mainstream, topologies explode No good systems out there Proprietary stacks rule (ESRI, Oracle) Open Government Data Shapefiles suck.
  • 14.
    Persistence backends inGIS Shapefiles PostGIS MySQL Oracle Spatial ESRI GeoCouch Cassandra (?) Neo4j Spatial
  • 15.
    Current challenges inSpatial Domain and Spatial interconnections Unstructured domain data Routing Topology handling No good OSS full GIS stack
  • 16.
    The Neo4j Spatialstack OpenLayers PHP AJAX WMS Editing JS WMF C# Rails Spring Django Roo GeoServer uDig GeoMaya REST Java Scripting GeoTools Neo4j Spatial Neo4j
  • 17.
  • 18.
    The OpenStreetMap dataset Wiki for Spatial info Freely available data Very unstructured, free tagging Points, Ways, Relations, Tags, Changesets Changes can be pushed back Used for other purposes Great coverage in interesting places (towns, disasters etc)
  • 19.
  • 20.
  • 21.
    GSoC 2010 DavideSavazzi Geotools & GeoServer Routing uDig
  • 22.
    Connecting and Splitting Layer1 Layer1 Layer2 Layer2 Layer3 Layer3 Why have layers at all? Simpler renderers Historical Data sources
  • 23.
    GSoC 2010 -Routing
  • 24.
    Connecting and Splitting Routing OSM Dynamic Layers
  • 25.
  • 26.
    Neo4j dynamic layers Geometry Layer1 Encoder Dynamic Query Layer2 Dynamic Styles Layer3 Dynamic Meta-Inf Connected domain data Neo4j Spatial GIS and Spatial stacks
  • 27.
    OpenStreetMap Dynamic OSM Laye rs Inde x (RTre e )
  • 28.
  • 29.
  • 30.
  • 31.
    Future Complexspatial mapping and analytics made easy Editing Fine Grained Geotools Feature Editing OSM Editor OSM Caching sub-graphs (desktop & mobile) More Dynamic Layers & Shapefile export Topology Persist all topological results in graph Benchmarking & Performance Improved indexing Composite index
  • 32.
    API References Wiki,Code, API references http://wiki.neo4j.org/content/Neo4j_Spatial http://github.com/neo4j/neo4j-spatial http://components.neo4j.org/neo4j-spatial Mailing list: neo4j@lists.neo4j.org http://neo4j.org/community/list/
  • 33.
    Questions? Image credit: lost again! Sorry :(
  • 34.

Editor's Notes

  • #3 The current success and popularity of NoSQL data models has been driven by the internet, and the associated explosion in the volume and interconnectedness of data.
  • #4 EE
  • #5 This example does highlight a few things about semi-structured data, schema-less databases and even opens the conversation for some discussions on performance (implicit indexes through local search, etc.)
  • #6 Lightweight and embedded: single jar of ~500k [demo]
  • #7 Fully transactional: ie complete ACID, supports JTA/JTS, 2PC, deadlock detection, transaction recovery and all the rest [demo]
  • #9 Lightweight and embedded: single jar of ~500k [demo]
  • #10 • includes high performance graph algorithms • routes with live changing data • integrates easily with any domain graph
  • #11 • traverses millions of friends per second • maps directly to friend-of-a-friend • quickly performs deep recommendations
  • #12 • explores what-if failures • reveals root cause • determines actual operating cost
  • #13 • can handle billions of ad-hoc relationships • traverses millions of nodes per second • maps directly to your MDM domain
  • #14 Storage: plugable – dataset, layer, encoder Search: Indexing is currently an R-Tree, but it is possible to plug in any custom mechanism conforming to the interface. Multi-dimensional index Spatial indices (quad-tree, R-tree, kn-tree, SFCs) Composite indices and dynamic indices Lucene
  • #15 Storage: plugable – dataset, layer, encoder Search: Indexing is currently an R-Tree, but it is possible to plug in any custom mechanism conforming to the interface. Multi-dimensional index Spatial indices (quad-tree, R-tree, kn-tree, SFCs) Composite indices and dynamic indices Lucene
  • #16 Storage: plugable – dataset, layer, encoder Search: Indexing is currently an R-Tree, but it is possible to plug in any custom mechanism conforming to the interface. Multi-dimensional index Spatial indices (quad-tree, R-tree, kn-tree, SFCs) Composite indices and dynamic indices Lucene
  • #19 Storage: plugable – dataset, layer, encoder Search: Indexing is currently an R-Tree, but it is possible to plug in any custom mechanism conforming to the interface. Multi-dimensional index Spatial indices (quad-tree, R-tree, kn-tree, SFCs) Composite indices and dynamic indices Lucene