Skip to content

Commit

Permalink
Add example for aggregate collect functions
Browse files Browse the repository at this point in the history
fix #24962
  • Loading branch information
DelazJ authored and nyalldawson committed Aug 31, 2020
1 parent 7c6ce37 commit fc1f3bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion resources/function_help/json/aggregate
Expand Up @@ -17,6 +17,7 @@
{ "expression":"aggregate(layer:='rail_stations',aggregate:='sum',expression:=\"passengers\",filter:=\"class\">3)", "returns":"sums up all values from the \"passengers\" field from features where the \"class\" attribute is greater than 3 only"},
{ "expression":"aggregate(layer:='rail_stations',aggregate:='concatenate', expression:=\"name\", concatenator:=',')", "returns":"comma separated list of the name field for all features in the rail_stations layer"},
{ "expression":"aggregate(layer:='countries', aggregate:='max', expression:=\"code\", filter:=intersects( $geometry, geometry(@parent) ) )", "returns":"The country code of an intersecting country on the layer 'countries'"},
{ "expression":"aggregate(layer:='rail_stations',aggregate:='sum',expression:=\"passengers\",filter:=contains( @atlas_geometry, $geometry ) )", "returns":"sum of all values from the passengers field in the rail_stations within the current atlas feature"}
{ "expression":"aggregate(layer:='rail_stations',aggregate:='sum',expression:=\"passengers\",filter:=contains( @atlas_geometry, $geometry ) )", "returns":"sum of all values from the passengers field in the rail_stations within the current atlas feature"},
{ "expression":"aggregate(layer:='rail_stations', aggregate:='collect', expression:=centroid($geometry), filter:=\"region_name\" = attribute(@parent,'name') )", "returns":"aggregates centroid geometries of the rail_stations of the same region as current feature"}
]
}
3 changes: 2 additions & 1 deletion resources/function_help/json/collect
Expand Up @@ -9,6 +9,7 @@
{"arg":"filter", "optional":true, "description":"optional expression to use to filter features used to calculate aggregate"}
],
"examples": [
{ "expression":"collect( $geometry )", "returns":"multipart geometry of aggregated geometries"}
{ "expression":"collect( $geometry )", "returns":"multipart geometry of aggregated geometries"},
{ "expression":"collect( centroid($geometry), group_by:=\"region\", filter:= \"use\" = 'civilian' )", "returns":"aggregated centroids of the civilian features based on their region value"}
]
}

0 comments on commit fc1f3bf

Please sign in to comment.