In QGIS 3.16.0 I have a postgis-polygon-layer with a field "array_polygon" which contains an array.
When digitizing a postgis-point-layer-point I would like to use the different array-values of the intersecting polygon in different fields as a default value to avoid lots of spatial queryies (one for every field).
The polygon layer has an "array_polygon"-field with type "QVariantList" and type name "_float8" and length "-1" and precision "0". The point layer has an "polygon_info"-fiel with type "QVariantList" and type name "_float8" and length "-1" and precision "0" too.
The "polygon_info"- field of the point-layer has a default value like
array_get(aggregate(
layer:= 'my_polygon_layer',
aggregate:='array_agg',
expression:=array_polygon,
filter:=intersects($geometry, geometry(@parent))),0)
The preview shows array-values as expected:
But the "polygon-info"-field in my point-layer stays empty after digitizing a point over a polygon:
(I tried the expression without "array_get("...",0)
too but without success).
My other fields - which should refer to "polygon_info"-array have a default value like
array_get( "polygon_info" ,0)
(I checked
array_get( current_value("polygon_info") ,0)
too) but every approach has a NULL-result too.
What is wrong?
- Has the expression or field-definition to be different to store the evaluated array (as seen in preview) in my point-attribute-table ?
- Is the spatial-query not carried out before the default-values are set - how can I force QGIS to make the spatial query first and after that extracting the values from this field?
- Or is my expression wrong - which alternative is correct ?
overlay_intersects
expression. Something like (pseudo expression)if ( overly_intersescts, your_expression, empty)
. And, as mentioned by @MrXsquared, try converting the output to a string and create a string field for testingarray_get(array,0)
- 0 for first element.