spatial.getFeatureCount

过程

返回图层中的要素数量

签名

spatial.getFeatureCount(name :: STRING) :: (count :: INTEGER)

输入参数

名称 类型 默认 描述

名称 (name)

STRING

null

层的名称

输出参数

名称 类型 描述

count

INTEGER(整数)

示例

统计不同图层类型中的要素数量

创建点图层

CALL spatial.addPointLayer('count_layer')

统计空图层中的要素数量

CALL spatial.getFeatureCount('count_layer') YIELD count
表 1. 结果
count
0

向图层添加一个节点

CREATE (n:Node {latitude: 60.1, longitude: 15.2, name: 'first'})
WITH n
CALL spatial.addNode('count_layer', n) YIELD node
RETURN node

添加一个要素后的统计

CALL spatial.getFeatureCount('count_layer') YIELD count
表 2. 结果
count
1

一次性添加多个节点

UNWIND range(1,3) as i
CREATE (n:Node {id: i, latitude: (60.0 + i * 0.1), longitude: (15.0 + i * 0.1)})
WITH collect(n) as nodes
CALL spatial.addNodes('count_layer', nodes) YIELD count
RETURN count

添加多个要素后的统计

CALL spatial.getFeatureCount('count_layer') YIELD count
表 3. 结果
count
4

创建 WKT 层

CALL spatial.addWKTLayer('wkt_layer', 'wkt')

统计空 WKT 图层中的要素数量

CALL spatial.getFeatureCount('wkt_layer') YIELD count
表 4. 结果
count
0

添加一个 WKT 点

CALL spatial.addWKT('wkt_layer', 'POINT(15.2 60.1)') YIELD node RETURN node

添加一个 WKT 线串

CALL spatial.addWKT('wkt_layer', 'LINESTRING (15.2 60.1, 15.3 60.1)') YIELD node RETURN node

统计 WKT 图层中的要素数量

CALL spatial.getFeatureCount('wkt_layer') YIELD count
表 5. 结果
count
2

获取图层中的要素数量

CALL spatial.addPointLayer('count_layer') YIELD node
表 6. 结果
节点
(:SpatialLayer {
    geomencoder: "SimplePointEncoder",
    index_type: "rtree",
    layer: "count_layer",
    layer_type: "SimplePointLayer"
})

获取空图层的计数

CALL spatial.getFeatureCount('count_layer') YIELD count
表 7. 结果
count
0

向图层添加两个点

CREATE (n1:Point {latitude: 60.1, longitude: 15.2, name: 'point1'})
CREATE (n2:Point {latitude: 60.3, longitude: 15.5, name: 'point2'})
WITH n1, n2
CALL spatial.addNode('count_layer', n1) YIELD node as added1
WITH n2, added1
CALL spatial.addNode('count_layer', n2) YIELD node as added2
RETURN added1, added2

添加点后获取计数

CALL spatial.getFeatureCount('count_layer') YIELD count
表 8. 结果
count
2
© . This site is unofficial and not affiliated with Neo4j, Inc.