28 Feb 2022

QGIS 3: Geometry Generator Expression for Points at Line Intersections

A solution for symbolizing line intersections between the current layer's features and another layer's features ('Tracks Subset=Detail'). The
generate_series
is used with an
aggregate
which yields the number if features in the other layer used for the intersection. The
array_foreach
iterates over all features of the other layer and intersects each line with the input layer's current feature. The
array_filter
is needed to filter out the epmty geometries that could result after the intersection. If you wouldn't do this, the code would break when calling
collect_geometries
, which is needed to finally convert the array of geometries into a valid, digestible geometry collection, fed into the geometry generator with checking Point/Multi-POint as geometry type..
with_variable ('my_series', generate_series(1, aggregate(layer:='Tracks Subset=Detail', aggregate:='max', expression:="id")),
	collect_geometries(
		array_filter(
		array_foreach(@my_series, if(is_empty_or_null( 
			intersection(geometry(get_feature('Tracks Subset=Detail', 'id', @element)),
			$geometry)), 'x', intersection(geometry(get_feature('Tracks Subset=Detail', 'id', @element)),
			$geometry))
			), 
		@element != 'x'
	)
  )
)

No comments :

Post a Comment