Question about virtual fields accessing layer attributes from other vector layers

25 views
Skip to first unread message

Colin Mazengarb

unread,
Apr 9, 2026, 10:56:12 PMApr 9
to QGIS Australia User Group
Hi All,

question for a Friday!

I have been using the raster_value function to attach values from raster layers to a point layer virtual field. Absolutely fantastic as it is simpler than the sample raster values function! However, is it possible to do this with with vector data rather than a classic spatial join process? For instance, can a point layer virtual field extract a nominated field attribute in an underlying polygon?

Cheers
Colin


Tasadduq Hanif

unread,
Apr 10, 2026, 12:55:21 AMApr 10
to QGIS Australia User Group

To pull a polygon attribute into a point's virtual field (the vector version of raster_value), use the overlay_within function.

array_first(overlay_within('Polygon_Layer_Name', "Field_to_Extract"))

Why this works:
  1. overlay_within: Finds the polygon the point is sitting inside.

  2. "Field_to_Extract": Identifies the specific column data you want to grab.

  3. array_first: Since spatial joins can technically find multiple overlaps, this ensures you get a single, clean value back.

Key Benefits:
  • Live: If you move the point, the value updates automatically.

  • Dynamic: No need to run a "Join Attributes by Location" every time data changes.

  • Clean: Keeps your attribute table organized without creating "joined" duplicate layers.

Best Wishes,
Tasadduq Hanif foynder of...https://simplemehandidesigns.com/

Colin Mazengarb

unread,
Apr 11, 2026, 12:27:44 AM (13 days ago) Apr 11
to QGIS Australia User Group
Hi Tasadduq, 

awesome thanks! Got it working. As provided in your example, the field name must be enclosed in double quotes not single quotes to indicate it is a field! This tripped me up as I was double clicking on the field name (in the map layers panel) to enter it into the expression and this produces the name in single quotes, which is static text. 

Thanks again,this is another game changer for the reasons you outlined very well, and same as the raster equivalent.

Always something new to learn!!!

cheers
Colin 

Tasadduq Hanif

unread,
Apr 11, 2026, 8:12:46 AM (13 days ago) Apr 11
to QGIS Australia User Group
Hi Colin, 

You’re always welcome - it’s my pleasure. It’s an honor for me to be of help to you.


Best Wishes,

Tasadduq Hanif.

Reply all
Reply to author
Forward
0 new messages