QGIS API Documentation 3.41.0-Master (af5edcb665c)
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" ), QObject::tr( "Input layer" ), QList<int>() << static_cast<int>( Qgis::ProcessingSourceType::VectorPoint ) ) );
55 addParameter( new QgsProcessingParameterField( QStringLiteral( "DATETIME_FIELD" ), QObject::tr( "Date/time field" ), QVariant(), QStringLiteral( "INPUT" ), Qgis::ProcessingFieldParameterDataType::DateTime, false, false ) );
56
57 addParameter( new QgsProcessingParameterNumber( QStringLiteral( "MIN_SIZE" ), QObject::tr( "Minimum cluster size" ), Qgis::ProcessingNumberParameterType::Integer, 5, false, 1 ) );
58 addParameter( new QgsProcessingParameterDistance( QStringLiteral( "EPS" ), QObject::tr( "Maximum distance between clustered points" ), 1, QStringLiteral( "INPUT" ), false, 0 ) );
59 auto durationParameter = std::make_unique<QgsProcessingParameterDuration>( QStringLiteral( "EPS2" ), QObject::tr( "Maximum time duration between clustered points" ), 0, false, 0 );
60 durationParameter->setDefaultUnit( Qgis::TemporalUnit::Hours );
61 addParameter( durationParameter.release() );
62
63 auto dbscanStarParam = std::make_unique<QgsProcessingParameterBoolean>( QStringLiteral( "DBSCAN*" ), QObject::tr( "Treat border points as noise (DBSCAN*)" ), false, true );
64 dbscanStarParam->setFlags( dbscanStarParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
65 addParameter( dbscanStarParam.release() );
66
67 auto fieldNameParam = std::make_unique<QgsProcessingParameterString>( QStringLiteral( "FIELD_NAME" ), QObject::tr( "Cluster field name" ), QStringLiteral( "CLUSTER_ID" ) );
68 fieldNameParam->setFlags( fieldNameParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
69 addParameter( fieldNameParam.release() );
70 auto sizeFieldNameParam = std::make_unique<QgsProcessingParameterString>( QStringLiteral( "SIZE_FIELD_NAME" ), QObject::tr( "Cluster size field name" ), QStringLiteral( "CLUSTER_SIZE" ) );
71 sizeFieldNameParam->setFlags( sizeFieldNameParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
72 addParameter( sizeFieldNameParam.release() );
73
74 addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT" ), QObject::tr( "Clusters" ), Qgis::ProcessingSourceType::VectorPoint ) );
75
76 addOutput( new QgsProcessingOutputNumber( QStringLiteral( "NUM_CLUSTERS" ), QObject::tr( "Number of clusters" ) ) );
77}
78
79QString QgsStDbscanClusteringAlgorithm::shortHelpString() const
80{
81 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"
82 "For more details, please see the following papers:\n"
83 "* 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"
84 "* Birant, Derya, and Alp Kut. \"ST-DBSCAN: An algorithm for clustering spatial–temporal data.\" Data & Knowledge Engineering 60.1 (2007): 208-221.\n"
85 "* Peca, I., Fuchs, G., Vrotsou, K., Andrienko, N. V., & Andrienko, G. L. (2012). Scalable Cluster Analysis of Spatial Events. In EuroVA@ EuroVis." );
86}
87
88QgsStDbscanClusteringAlgorithm *QgsStDbscanClusteringAlgorithm::createInstance() const
89{
90 return new QgsStDbscanClusteringAlgorithm();
91}
92
@ 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.