• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
North River Geographic Systems Inc

North River Geographic Systems Inc

Geospatial Problem Solving

  • Home
  • About NRGS
  • Training
  • Blog
  • Resources
    • QGIS Tutorials and Hacks
    • GDAL Tutorials and Hacks
    • PostGIS Tutorials and Hacks
    • GRASS Tutorials and Hacks
    • OSM Tutorials and Hacks
  • Services
    • Support and Services
    • Tennessee NG911 Address Server
    • Forestry Database Services
    • Conservation GIS
  • Portfolio
  • Show Search
Hide Search

QGIS Aggregate Function using Contains

  • Software: QGIS 3.20
  • OS: Any
  • Updated: August 2021

In this example I have some data which are points (Parks) and I want to pull the an attribute from a polygon layer (Parcels) into the data – BUT I don’t want to do a spatial join. In this case we are going to use the aggregate function in field calculator. The Aggregate function allows you to pull data from another layer into your current layer without having to run a processing tool.

We have points and polygons.

Edit the point layer and open the field calculator

From there you want to create a new field that will hold the tax_map_no in the point layer. I will call that field parcel and and make it a text string.

The aggregate expression will look like the following:

aggregate(
 layer:= 'parcels',
 aggregate:='concatenate',
 expression:= "tax_map_no",
 concatenator:=', ',
 filter:=contains($geometry, geometry(@parent))
 )

That little bit of code is doing the following: It’s using the parcel layer and return the values held in “tax_map_no”. In case there is more than one value (there won’t be in this case) use a comma as a delimiter. The filter section specifies to make sure the point features ($geometry) reside within the geometry of the Parcels (@parent)

At the end you have a new field in your point layer that has the value from the polygon.

Want QGIS Training? Need help with a project? Give us a shout at info at northrivergeographic.com

Primary Sidebar

Calendar

July 2022
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031
« Jun    

What we talk about

addresses ArcGIS ASPRS Athens Atlanta Beer Cartography Chattanooga Community Conference Data Do Some Good Education ESRI Forestry FOSS4G foss4gna Fulcrum gaurisa ga urisa Gdal Georgia GeoServer GIS GISP Google GRASS Lidar MAGS open source OpenStreetMap osgeo OSM postgis Python QGIS raleigh Rambling Small Business Tennessee TNGIC Topology Training URISA usvi

North River Geographic Systems Inc

  • Home
  • About NRGS
  • Training
  • Blog
  • Resources
  • Services
  • Portfolio