Add new field in a point layer with an attribute from another layer in QGIS

There is also a possibility without need to install a plugin, simply using this expression (available since QGIS 3.16):

array_to_string (overlay_within('polygon', id))

Add the function to_int () to get an integer instead of a string as output type.

enter image description here


You can use refFunctions plugin. It adds custom user functions to QGIS Field Calculator. Then, you can add a new field to the point layer with the id of the polygon that contains it using the following expression in Field Calculator for the point layer:

geomwithin( 'polygon_layer_name', 'id_field_of_polygon_layer' )

enter image description here