I am getting this weird error while using join attributes by location in QGIS, I have two layers - Source & Target. I am joining by target to source features using intersect option in join attributes by location.

enter image description here

Here is my script:

QgisAll_layers = QgsProject.instance().mapLayers().values()
path = QgsProject.instance().absolutePath() 
joined = str(path) + "//source_target_joined.shp"
unjoined = str(path) + "//source_target_unjoined.shp"

processing.run("qgis:joinattributesbylocation", {
                'INPUT': Source,
                'JOIN': Target,
                'PREDICATE': [0], 'JOIN_FIELDS': [], 'METHOD': 0, 'DISCARD_NONMATCHING': False, 'PREFIX': 'jj',
                'OUTPUT': joined, 'NON_MATCHING': unjoined})

Joined attribute table not having target field values.

enter image description here

I understand that the spatial join of features is not happening due to some reasons, it is not able to spatially identify the features in my script.

The Join Count is coming zero, even when I have tried to reproject both the vector layers to project CRS. I have tried to add spatial index to both the points but still it did not work.

enter image description here

  • How do you add the results to QGIS after using processing.run in the script above? Did you try processing.runAndLoadResults instead of processing.run? Commented Jan 14, 2022 at 10:50
  • Hi @KadirŞahbaz, I think the issue now is that the join by location is not working at all even though when I reprojected both the layers into project epsg crs. The joined count is coming 0. I am not able to understand why this is not working whereas there is no error in geometry? Commented Jan 14, 2022 at 11:19

1 Answer 1


It seems you are using point layers, are your geometries exactly coincident for the points you expect to join? For point geometries with several decimal figures, especially after reprojecting, it may be that they do not intersect. You could try Join by nearest and then filter out any joins that are above an acceptable distance threshold.

enter image description here

enter image description here

  • I had the same problem when joining attributes from my point layer to my line layer. Only some joins worked, others were left NULL. Same projection, "check validity" returned no errors and "fix geometries" didn't help. This method is a very good workaround. According to "distance", it seems my layer does consider some points to be farther away. Commented Jul 13, 2023 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.