spatial.removeLayer

Procedure

Removes the given layer. Deletes the nodes the layer created (e.g. by spatial.addWKT); nodes added with spatial.addNode are only removed from the index

Signature

spatial.removeLayer(name :: STRING)

Input parameters

Name Type Default Description

name

STRING

null

The name of the layer

Deleted and kept nodes

Node On spatial.removeLayer

Created by the layer (spatial.addWKT, spatial.addWKTs, shapefile import …), labelled _SpatialManagedGeometry

deleted, with its relationships

Added with spatial.addNode / spatial.addNodes, or created by the OSM importer

removed from the index; node, relationships and properties are kept

A node labelled _SpatialManagedGeometry belongs to the layer that created it. Don’t add it to other layers: removing its layer deletes it from all of them.

Nodes created by release 2026.10.0 or earlier

These nodes have no _SpatialManagedGeometry label, so spatial.removeLayer keeps them. To delete them with the layer, label them first. This example labels the nodes of an RTree layer that have no other labels and no relationships besides the index reference. For a layer with a custom referenceRelationshipType, replace RTREE_REFERENCE with that type.

The query can’t tell layer-created nodes from your own nodes of the same shape: a node added with spatial.addNode that has no labels and no other relationships matches too, and spatial.removeLayer then deletes it. Run it with RETURN g instead of SET first, and narrow the WHERE clause until it matches only the nodes the layer created.
MATCH (:SpatialLayer {layer: $name})-[:RTREE_ROOT]->()-[:RTREE_CHILD*0..]->()-[:RTREE_REFERENCE]->(g)
WHERE size(labels(g)) = 0 AND COUNT { (g)--() } = 1
SET g:_SpatialManagedGeometry

Examples

Add and Remove a layer

CALL spatial.addWKTLayer('geom','wkt')
Table 1. Result
node
(:SpatialLayer {
    geomencoder: "WKTGeometryEncoder",
    geomencoder_config.bboxProperty: "bbox",
    geomencoder_config.geomProperty: "wkt",
    index_config.maxNodeReferences: 100,
    index_config.referenceRelationshipType: "RTREE_REFERENCE",
    index_config.shouldMergeTrees: false,
    index_config.splitMode: "greene",
    index_type: "rtree",
    layer: "geom",
    layer_type: "EditableLayer"
})
CALL spatial.layers()
Table 2. Result
name signature

geom

EditableLayer(name='geom', encoder=WKTGeometryEncoder(geom='wkt', bbox='bbox'))

CALL spatial.removeLayer('geom')
Result

No results

CALL spatial.layers()
Result

No results