I have two layers in QGIS. The first one contains buildings and the second one contains blocks. Now I want to add the ID of the block to all buildings inside this block.
Are there any functions in QGIS available for this?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
Option 1: Use
join attributes by location.
Option 2: Use the field calculator with the following code (adaption needed)
Please note: Make sure, the field type you are creating fits the source field. Furthermore, you need to use the layer name provided by the field calculator, not the displayed name. You need to change the
expression-value to the column you want to copy. Also you might need to change the
filter value. This is some rather advanced stuff.
Install the RefFunctions plugin. This gives you additional functions to use in the Field Calculator. These new functions are simpler to use than the built-in aggregate functions.
Use the Field Calculator to add a new field to the building layer, with this expression:
geomintersects('block layer', 'ID')
Substitute the actual names of your block layer and the ID field in the block layer.