QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgsalgorithmstdbscanclustering.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmstdbscanclustering.cpp
3 ---------------------
4 begin : July 2018
5 copyright : (C) 2018 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19
21
22QString QgsStDbscanClusteringAlgorithm::name() const
23{
24 return QStringLiteral( "stdbscanclustering" );
25}
26
27QString QgsStDbscanClusteringAlgorithm::displayName() const
28{
29 return QObject::tr( "ST-DBSCAN clustering" );
30}
31
32QString QgsStDbscanClusteringAlgorithm::shortDescription() const
33{
34 return QObject::tr( "Clusters spatiotemporal point features using a time and density based scan algorithm." );
35}
36
37QStringList QgsStDbscanClusteringAlgorithm::tags() const
38{
39 return QObject::tr( "clustering,clusters,density,based,points,temporal,time,interval,duration,distance" ).split( ',' );
40}
41
42QString QgsStDbscanClusteringAlgorithm::group() const
43{
44 return QObject::tr( "Vector analysis" );
45}
46
47QString QgsStDbscanClusteringAlgorithm::groupId() const
48{
49 return QStringLiteral( "vectoranalysis" );
50}
51
52void QgsStDbscanClusteringAlgorithm::initAlgorithm( const QVariantMap & )
53{
54 addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "INPUT" ),
55 QObject::tr( "Input layer" ), QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) ) );
56 addParameter( new QgsProcessingParameterField( QStringLiteral( "DATETIME_FIELD" ),
57 QObject::tr( "Date/time field" ), QVariant(),
58 QStringLiteral( "INPUT" ), Qgis::ProcessingFieldParameterDataType::DateTime, false, false ) );
59
60 addParameter( new QgsProcessingParameterNumber( QStringLiteral( "MIN_SIZE" ), QObject::tr( "Minimum cluster size" ),
62 addParameter( new QgsProcessingParameterDistance( QStringLiteral( "EPS" ),
63 QObject::tr( "Maximum distance between clustered points" ), 1, QStringLiteral( "INPUT" ), false, 0 ) );
64 auto durationParameter = std::make_unique<QgsProcessingParameterDuration>( QStringLiteral( "EPS2" ),
65 QObject::tr( "Maximum time duration between clustered points" ), 0, false, 0 );
66 durationParameter->setDefaultUnit( Qgis::TemporalUnit::Hours );
67 addParameter( durationParameter.release() );
68
69 auto dbscanStarParam = std::make_unique<QgsProcessingParameterBoolean>( QStringLiteral( "DBSCAN*" ),
70 QObject::tr( "Treat border points as noise (DBSCAN*)" ), false, true );
71 dbscanStarParam->setFlags( dbscanStarParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
72 addParameter( dbscanStarParam.release() );
73
74 auto fieldNameParam = std::make_unique<QgsProcessingParameterString>( QStringLiteral( "FIELD_NAME" ),
75 QObject::tr( "Cluster field name" ), QStringLiteral( "CLUSTER_ID" ) );
76 fieldNameParam->setFlags( fieldNameParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
77 addParameter( fieldNameParam.release() );
78 auto sizeFieldNameParam = std::make_unique<QgsProcessingParameterString>( QStringLiteral( "SIZE_FIELD_NAME" ),
79 QObject::tr( "Cluster size field name" ), QStringLiteral( "CLUSTER_SIZE" ) );
80 sizeFieldNameParam->setFlags( sizeFieldNameParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
81 addParameter( sizeFieldNameParam.release() );
82
83 addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT" ), QObject::tr( "Clusters" ), Qgis::ProcessingSourceType::VectorPoint ) );
84
85 addOutput( new QgsProcessingOutputNumber( QStringLiteral( "NUM_CLUSTERS" ), QObject::tr( "Number of clusters" ) ) );
86}
87
88QString QgsStDbscanClusteringAlgorithm::shortHelpString() const
89{
90 return QObject::tr( "Clusters point features based on a 2D implementation of spatiotemporal density-based clustering of applications with noise (ST-DBSCAN) algorithm.\n\n"
91 "For more details, please see the following papers:\n"
92 "* Ester, M., H. P. Kriegel, J. Sander, and X. Xu, \"A Density-Based Algorithm for Discovering Clusters in Large Spatial Databases with Noise\". In: Proceedings of the 2nd International Conference on Knowledge Discovery and Data Mining, Portland, OR, AAAI Press, pp. 226-231. 1996\n"
93 "* Birant, Derya, and Alp Kut. \"ST-DBSCAN: An algorithm for clustering spatial–temporal data.\" Data & Knowledge Engineering 60.1 (2007): 208-221.\n"
94 "* Peca, I., Fuchs, G., Vrotsou, K., Andrienko, N. V., & Andrienko, G. L. (2012). Scalable Cluster Analysis of Spatial Events. In EuroVA@ EuroVis." );
95}
96
97QgsStDbscanClusteringAlgorithm *QgsStDbscanClusteringAlgorithm::createInstance() const
98{
99 return new QgsStDbscanClusteringAlgorithm();
100}
101
103
104
@ VectorPoint
Vector point layers.
@ DateTime
Accepts datetime fields.
@ Advanced
Parameter is an advanced parameter which should be hidden from users by default.
A numeric output for processing algorithms.
A double numeric parameter for distance values.
A feature sink output for processing algorithms.
An input feature source (such as vector layers) parameter for processing algorithms.
A vector layer or feature source field parameter for processing algorithms.
A numeric parameter for processing algorithms.