With neo4j-spatial, we can load data directly from a shapefile. The procedure is called spatial.importShapefile and accepts a single parameter: the path to the data file. It will automatically create a new spatial layer to hold the data, with a name derived from the input file name, and create a node for each geometry.
The full syntax is as follows:
- First, let's create the layer, with a given name and type:
CALL spatial.addLayer("manhattan_districts")
- Import the shapefile data into this newly created layer:
CALL spatial.importShapefile("/<absolute_path_to>/manhattan_districts.shp")
After you run this procedure, your database contains twelve more nodes, one for each district contained in the shapefile. Each of these nodes contains the following information:
{
"CD_ID": 4,
"geometry": {....},
"gtype": 6,
"ID": 1,
"bbox": [
-74.01214813183593,
40.7373608893982,
...