Searching for spatial nodes into geometry box from shapefile

144 views
Skip to first unread message

Arnaud Drazek

unread,
Aug 20, 2014, 9:11:11 AM8/20/14
to ne...@googlegroups.com
Hello neo4jier !

I need to import a Shapefile (easy !) and then I need to get the geometries from this shapefile (much difficult). 
Did you know how I could transform a shapefile into geometry in order to search geo nodes from a custom layer living into this geometries ?

I don't know if i'm really clear ..

Thanks for your help,

Regards,

Arnaud

Jim Biard

unread,
Aug 20, 2014, 10:54:02 AM8/20/14
to ne...@googlegroups.com
Arnaud,

If you are using the Neo4j Spatial plugin, geometries will be computed from the shapes if you use the shape file importer. They will be in the Well-Known Binary (WKB) format, but they will be present. Are you looking for something more or different than this?

Grace and peace,

Jim

Arnaud DRAZEK

unread,
Aug 20, 2014, 11:29:45 AM8/20/14
to ne...@googlegroups.com
Hello Jim,

Thanks a lot for answering. 
My shapefile (that I import with the ShapeFileImporter) contains the boundaries of a french district. I import it in a new layer.
I want know search for the geo nodes based on the spatial plugin which are contained in this area : I guess with the geopipeline ? But for that I need a Geometry object. 

I specify that I work with java and the embedded graph way.

Regards,

Arnaud


--
You received this message because you are subscribed to a topic in the Google Groups "Neo4j" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/neo4j/OZfC4qQ7nso/unsubscribe.
To unsubscribe from this group and all its topics, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Craig Taverner

unread,
Aug 29, 2014, 8:10:42 AM8/29/14
to ne...@googlegroups.com
Hi Arnaud,

If you are using the Java API, then there are several ways to find objects in the index. It sounds like you want something like 'find all Geometries that are contained within this area'? Or perhaps intersecting an area? Can you explain in more detail what your actual query is, then I can suggest sample code that will answer that query?

Some places to look in the test code that might answer your question:
  • Simple index query with a command like (extracted from TestSpatial.java):
    Geometry testArea = layer.getGeometryFactory()........ // make your geometry here
    SearchIntersect searchQuery = new SearchIntersect(layer, testArea);
    SearchRecords results = index.search(searchQuery);
    //now iterate over the results
  • Or try the GeoPipeline (extracted from GeoPipesTest.java):
    GeoPipeline.start( osmLayer ).windowIntersectionFilter( 10, 40, 20, 56.0583531 ).count()
The test code is a great place for finding out how to do things. There are many examples. Of course, if you provide your actual query, I could provide an example that really matches.

Regards, Craig


--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.

Arnaud DRAZEK

unread,
Sep 8, 2014, 8:36:56 AM9/8/14
to ne...@googlegroups.com
Hi Craig,

Thanks a lot for your answer. But I think I do not explain very well my need...

I need to build geometries from a shape file in order to search in on an another layer.

In other words : 
I have a shape file as the attachment. I need to build geometries from this shape file. And then I need to search geo nodes from a layer that are contained in this geometries.

I don't know how to get geometries from this shape file to pass them to a method of the geopipeline (as a windowIntersetionFilter as well).

Sorry for my explanation, I'm not the god of english ...

Regards,

Arnaud
intercommunalites_shp.zip

Craig Taverner

unread,
Sep 9, 2014, 6:24:46 AM9/9/14
to ne...@googlegroups.com
Converting Shapefiles to JTS Geometries can be done easily with the GeoTools library gt-shapefile. We include this library in Neo4j Spatial, and use it in, for example in the ShapefileImporter. See the code at https://github.com/neo4j-contrib/spatial/blob/master/src/main/java/org/neo4j/gis/spatial/ShapefileImporter.java#L148.

If you don't want to write (or copy) this code, you could always use the ShapefileImporter to import Geometries to one layer, and then get the Geometry you want and use it in searching your other layers. For an example of using the ShapefileImporter see the test code at https://github.com/neo4j-contrib/spatial/blob/master/src/test/java/org/neo4j/gis/spatial/TestSpatial.java#L216.

Reply all
Reply to author
Forward
0 new messages