GithubHelp home page GithubHelp logo

llerradyoh / neo4j-spatial Goto Github PK

View Code? Open in Web Editor NEW

This project forked from neo4j-contrib/spatial

1.0 2.0 0.0 3.65 MB

Neo4j Spatial is a library of utilities for Neo4j that faciliates the enabling of spatial operations on data. In particular you can add spatial indexes to already located data, and perform spatial operations on the data like searching for data within specified regions or within a specified distance of a point of interest. In addition classes are provided to expose the data to geotools and thereby to geotools enabled applications like geoserver and uDig.

Home Page: http://components.neo4j.org/neo4j-spatial/

neo4j-spatial's Introduction

Neo4j Spatial

This is a first prototype of a library to store spatial data in the Neo4j open source graph database. You can import geometries from a shapefile and perform spatial searches.

The most common 2D geometries are supported:

  • (multi) point
  • (multi) linestring
  • (multi) polygon

Spatial queries implemented:

  • Contain
  • Cover
  • Covered By
  • Cross
  • Disjoint
  • Intersect
  • Intersect Window
  • Overlap
  • Touch
  • Within
  • Within Distance

Building

You need a Java 6 environment, Neo4J, JTS and GeoTools:

  • jta-1.1.jar
  • neo4j-kernel-1.0.jar
  • neo4j-commons-1.0.jar
  • jts-1.10.jar
  • geoapi-2.3-M1.jar
  • gt-api-2.6.3.jar
  • gt-shapefile-2.6.3.jar
  • gt-main-2.6.3.jar
  • gt-metadata-2.6.3.jar
  • gt-data-2.6.3.jar

Importing a shapefile

Spatial data is divided in Layers and indexed by a RTree.

GraphDatabaseService database = new EmbeddedGraphDatabase(storeDir);
try {
	ShapefileImporter importer = new ShapefileImporter(database);
    importer.importShapefile("roads.shp", "layer_roads");
} finally {
	database.shutdown();
}

Executing a spatial query

GraphDatabaseService database = new EmbeddedGraphDatabase(storeDir);
try {
	Transaction tx = database.beginTx();
    try {
    	SpatialDatabaseService spatialService = new SpatialDatabaseService(database);
        Layer layer = spatialService.getLayer("layer_roads");
        SpatialIndexReader spatialIndex = layer.getIndex();
        	
        Search searchQuery = new SearchIntersectWindow(new Envelope(xmin, xmax, ymin, ymax));
        spatialIndex.executeSearch(searchQuery);
	    List<SpatialDatabaseRecord> results = searchQuery.getResults();
	       	
		tx.success();
	} finally {
    	tx.finish();
    }	        	        	
} finally {
	database.shutdown();
}

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.