In QGIS 3.x how to copy the attributes from a point layer to a polygon layer where the point is within the polygon? In PostGIS I would do:
UPDATE poly_layer SET poly_layer.attribute = point_layer.attribute
FROM point_layer WHERE ST_Within( point_layer.geom, poly_layer.geom );
I realize that there is the "Join Attributes By Location" tool but it creates a new layer which is not convenient for my workflow. And I realize that if my two layers were both PostGIS layers I could simply execute my query in the DB Manager. But in this case I'm trying to copy attributes from a DXF point layer into an existing PostGIS polygon layer.
COPY
the data, andTRUNCATE
afterwards),UPDATE
(index powered; I also suggest to use plainST_Intersects
- except you expect points falling onto a line with sub-atomic precision*[this is only ever possible for highly modeled cases like regular grids]), and drop the point table again. AFAIK, in the *Field calculator you can only create virtual fields on DB layer sources - not sure rn if you can persist these as columns.UPDATE
will randomly select from a set of rows in cases where more than one point intersects a Polygon.