This would be easily done by simple Join, since an unique field CP
was already given to both Point and Polyline layers.
A Virtual Layer can be helpful:
SELECT Polyline_data.*, Point_data.AllMotorVehicles
FROM Point_data JOIN Polyline_data
ON Point_data.CP = Polyline_data.CP
This query will return a new polyline layer with AllMotorVehicles
field (copied from point layer), which can be used to color code these line segments.
processing.runalg()
can be called with only two arguments: a string indicating which algorithm to be used, e.g. "qgis:joinattributesbylocation"
, and a python dictionary object indicating parameter values which should not default, e.g. {PARAMETER_KEY:parameter_value}
. Parameters left out of the dictionary fall back on their default values. Use the parameter names as presented in processing.alghelp()
as keys.
To use the default behaviour, as the GUI Qgis call does, simply use default values. The complete call could be
processing.runalg("qgis:joinattributesbylocation",{
"TARGET":"path/to/points.shp",
"JOIN":"path/to/polygons.shp",
"OUTPUT":"path/to/output.shp"})
However, most processing algorithms have parameters that must be given. In that case, Qgis will present a warning such as:
Error: Missing parameter value for parameter PARAMETER_KEY
Using trial and error, can figure out which parameters are included in the minimum requirement. In this case, the complete call is:
processing.runalg("qgis:joinattributesbylocation",{
"TARGET":"path/to/points.shp",
"JOIN":"path/to/polygons.shp",
"PREDICATE":u'intersects',
"SUMMARY":0,
"KEEP":1,
"OUTPUT":"path/to/output.shp"})
Best Answer
I assume a situation like below:
school_layer_1
)school_layer_2
)And we want to know which schools are newly built.
Then we can use a Virtual Layer to find out suspicious schools.
The SQL query is:
The produced Virtual Layer (green circles) is a point layer with the records of difference between
school_layer_1
andschool_layer_2
.