Skip to content

Commit

Permalink
Add expressions to select features based on spatial relationship with…
Browse files Browse the repository at this point in the history
… another layer

Also replace some $-based functions with corrresponding variable
  • Loading branch information
DelazJ committed Apr 28, 2024
1 parent 75dff45 commit 7d8ccf8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions docs/user_manual/expressions/expression.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ using functions, layer fields and values. It contains the following widgets:
'max',
"ELEV", -- the field containing the altitude
-- and limit the airports to the region they are within
filter := within( $geometry, geometry( @parent ) )
filter := within( @geometry, geometry( @parent ) )
),
aggregate( -- finds airports at the same altitude in the region
'airports',
'concatenate',
"NAME",
filter := within( $geometry, geometry( @parent ) )
filter := within( @geometry, geometry( @parent ) )
and "ELEV" = @airport_alti
)
|| ' : ' || @airport_alti || 'm'
Expand Down Expand Up @@ -250,9 +250,17 @@ Some use cases of expressions
The previous expression could also be used to define which features
to label or show on the map.

* Select features that overlap a natural zone from the "lands" layer::

overlay_intersects( layer:='lands', filter:="zone_type"='Natural' )

* Count for each feature the number of buildings they contain::

array_length( overlay_contains( layer:='buildings', expression:=@id ) )

* Create a different symbol (type) for the layer, using the geometry generator::

point_on_surface( $geometry )
point_on_surface( @geometry )

* Given a point feature, generate a closed line (using ``make_line``) around its
geometry::
Expand All @@ -263,7 +271,7 @@ Some use cases of expressions
-- list of angles for placing the projected points (every 90°)
array:=generate_series( 0, 360, 90 ),
-- translate the point 20 units in the given direction (angle)
expression:=project( $geometry, distance:=20, azimuth:=radians( @element ) )
expression:=project( @geometry, distance:=20, azimuth:=radians( @element ) )
)
)

Expand All @@ -273,7 +281,7 @@ Some use cases of expressions
with_variable( 'extent',
map_get( item_variables( 'Map 1' ), 'map_extent' ),
aggregate( 'airports', 'concatenate', "NAME",
intersects( $geometry, @extent ), ' ,'
intersects( @geometry, @extent ), ' ,'
)
)

Expand Down

0 comments on commit 7d8ccf8

Please sign in to comment.