Neo4j: Is there a way to create a new node based on a group of nodes that meet certain criteria

I have a neo4j database up and running. I also have a process that runs every 5 minutes and what it does is to create nodes of type "Point".

"Point" has the following properties:

pointId, cameraId, classId, groupId, datetime

Nodes of type "Point" relate to themself if: pointId & cameraId & classId & groupId are the same.

Is it possible to somehow get all the nodes "Point" that relate themself and based on that group of nodes create a new node "Line" where "Line"-[:CONTAINS]->"Point"?

UPDATE: Following image shows what I have and what I need. For simplicity, I've just defined the property "camera", if a node Point shares the camera then it needs to be grouped.

thank you the above one is looking good but my requirement is the newly created node shouldn't have any property except UUID and my nodes are having different properties

I am a little confused. You diagram looks like you want to group nodes with the same cameraId into a group related to a Line node. The query below achieves this. It groups all the Point nodes by values of cameraId. It then creates a Line node (I added the id = cameraId of the group for tracking) and relates all the nodes to this node that have the same cameraId.

match(p:Point)
with p.cameraId as cameraId, collect(p) as group
merge(l:Line{id: cameraId})
forEach(i in group |
    merge(l)-[:CONTAINS]->(i)
)

Screen Shot 2023-01-21 at 12.22.38 PM.png

Screen Shot 2023-01-21 at 12.24.16 PM.png

Is this what you are looking for?

How about this:

match(p:Point)
with p.cameraId as cameraId, collect(p) as group
merge(l:Line{uuid: apoc.create.uuid()})
forEach(i in group |
    merge(l)-[:CONTAINS]->(i)
)

You need the apoc library installed.