QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Public Member Functions | List of all members
QgsGeometryAnalyzer Class Reference

The QGis class provides vector geometry analysis functions. More...

#include <qgsgeometryanalyzer.h>

Public Member Functions

bool buffer (QgsVectorLayer *layer, const QString &shapefileName, double bufferDistance, bool onlySelectedFeatures=false, bool dissolve=false, int bufferDistanceField=-1, QProgressDialog *p=nullptr)
 Create buffers for a vector layer and write it to a new shape file. More...
 
bool centroids (QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures=false, QProgressDialog *p=nullptr)
 Calculate the true centroids, or 'center of mass' for a vector layer and write it to a new shape file. More...
 
bool convexHull (QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures=false, int uniqueIdField=-1, QProgressDialog *p=nullptr)
 Create convex hull(s) of a vector layer and write it to a new shape file. More...
 
bool dissolve (QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures=false, int uniqueIdField=-1, QProgressDialog *p=nullptr)
 Dissolve a vector layer and write it to a new shape file. More...
 
bool eventLayer (QgsVectorLayer *lineLayer, QgsVectorLayer *eventLayer, int lineField, int eventField, QgsFeatureIds &unlocatedFeatureIds, const QString &outputLayer, const QString &outputFormat, int locationField1, int locationField2=-1, int offsetField=-1, double offsetScale=1.0, bool forceSingleGeometry=false, QgsVectorDataProvider *memoryProvider=nullptr, QProgressDialog *p=nullptr)
 Creates an event layer (multipoint or multiline) by locating features from a (non-spatial) event table along the features of a line layer. More...
 
bool extent (QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures=false, QProgressDialog *p=0)
 Create a polygon based on the extent of all (selected) features and write it to a new shape file. More...
 
QgsGeometrylocateAlongMeasure (double measure, const QgsGeometry *lineGeom)
 Returns linear reference geometry. More...
 
QgsGeometrylocateBetweenMeasures (double fromMeasure, double toMeasure, const QgsGeometry *lineGeom)
 Returns linear reference geometry as a multiline (or 0 if no match). More...
 
bool simplify (QgsVectorLayer *layer, const QString &shapefileName, double tolerance, bool onlySelectedFeatures=false, QProgressDialog *p=nullptr)
 Simplify vector layer using (a modified) Douglas-Peucker algorithm and write it to a new shape file. More...
 

Detailed Description

The QGis class provides vector geometry analysis functions.

Definition at line 35 of file qgsgeometryanalyzer.h.

Member Function Documentation

◆ buffer()

bool QgsGeometryAnalyzer::buffer ( QgsVectorLayer layer,
const QString shapefileName,
double  bufferDistance,
bool  onlySelectedFeatures = false,
bool  dissolve = false,
int  bufferDistanceField = -1,
QProgressDialog p = nullptr 
)

Create buffers for a vector layer and write it to a new shape file.

Parameters
layerinput vector layer
shapefileNamepath to the output shp
bufferDistancedistance for buffering (if no buffer field is specified)
onlySelectedFeaturesif true, only selected features are considered, else all the features
dissolveif true, merge all the buffers to a big multipolygon
bufferDistanceFieldindex of the attribute field that contains the buffer distance (or -1 if all features have the same buffer distance)
pprogress dialog (or 0 if no progress dialog is to be shown)

Definition at line 732 of file qgsgeometryanalyzer.cpp.

◆ centroids()

bool QgsGeometryAnalyzer::centroids ( QgsVectorLayer layer,
const QString shapefileName,
bool  onlySelectedFeatures = false,
QProgressDialog p = nullptr 
)

Calculate the true centroids, or 'center of mass' for a vector layer and write it to a new shape file.

Parameters
layerinput vector layer
shapefileNamepath to the output shp
onlySelectedFeaturesif true, only selected features are considered, else all the features
pprogress dialog (or 0 if no progress dialog is to be shown)

Definition at line 149 of file qgsgeometryanalyzer.cpp.

◆ convexHull()

bool QgsGeometryAnalyzer::convexHull ( QgsVectorLayer layer,
const QString shapefileName,
bool  onlySelectedFeatures = false,
int  uniqueIdField = -1,
QProgressDialog p = nullptr 
)

Create convex hull(s) of a vector layer and write it to a new shape file.

Parameters
layerinput vector layer
shapefileNamepath to the output shp
onlySelectedFeaturesif true, only selected features are considered, else all the features
uniqueIdFieldindex of the attribute field that contains the unique convex hull id (or -1 if all features have the same buffer distance)
pprogress dialog (or 0 if no progress dialog is to be shown)

Definition at line 365 of file qgsgeometryanalyzer.cpp.

◆ dissolve()

bool QgsGeometryAnalyzer::dissolve ( QgsVectorLayer layer,
const QString shapefileName,
bool  onlySelectedFeatures = false,
int  uniqueIdField = -1,
QProgressDialog p = nullptr 
)

Dissolve a vector layer and write it to a new shape file.

Parameters
layerinput vector layer
shapefileNamepath to the output shp
onlySelectedFeaturesif true, only selected features are considered, else all the features
uniqueIdFieldindex of the attribute field that contains the unique id to dissolve on (or -1 if all features should be dissolved together)
pprogress dialog (or 0 if no progress dialog is to be shown)

Definition at line 575 of file qgsgeometryanalyzer.cpp.

◆ eventLayer()

bool QgsGeometryAnalyzer::eventLayer ( QgsVectorLayer lineLayer,
QgsVectorLayer eventLayer,
int  lineField,
int  eventField,
QgsFeatureIds unlocatedFeatureIds,
const QString outputLayer,
const QString outputFormat,
int  locationField1,
int  locationField2 = -1,
int  offsetField = -1,
double  offsetScale = 1.0,
bool  forceSingleGeometry = false,
QgsVectorDataProvider memoryProvider = nullptr,
QProgressDialog p = nullptr 
)

Creates an event layer (multipoint or multiline) by locating features from a (non-spatial) event table along the features of a line layer.

Note that currently (until QgsGeometry supports m-values) the z-coordinate of the line layer is used for linear referencing

Parameters
lineLayerlayer with the line geometry
eventLayerlayer with features and location field
lineFieldjoin index in line layer
eventFieldjoin index in event layer
outputLayername of output file (can be empty if a memory layer is used)
outputFormatname of output format (can be empty if a memory provider is used to store the results)
unlocatedFeatureIdsout: ids of event features where linear referencing was not successful
locationField1attribute index of location field in event layer
locationField2attribute index of location end field (or -1 for point layer)
offsetFieldattribute index for offset field. Negative offset value = offset to left side, positive value = offset to right side
offsetScalefactor to scale offset
forceSingleGeometryforce layer to single point/line type. Feature attributes are copied in case of multiple matches
memoryProvidermemory provider to write output to (can be 0 if output is written to a file)
pprogress dialog or 0 if no progress dialog should be shown

Definition at line 890 of file qgsgeometryanalyzer.cpp.

◆ extent()

bool QgsGeometryAnalyzer::extent ( QgsVectorLayer layer,
const QString shapefileName,
bool  onlySelectedFeatures = false,
QProgressDialog p = 0 
)

Create a polygon based on the extent of all (selected) features and write it to a new shape file.

Parameters
layerinput vector layer
shapefileNamepath to the output shp
onlySelectedFeaturesif true, only selected features are considered, else all the features
pprogress dialog (or 0 if no progress dialog is to be shown)

Definition at line 265 of file qgsgeometryanalyzer.cpp.

◆ locateAlongMeasure()

QgsGeometry * QgsGeometryAnalyzer::locateAlongMeasure ( double  measure,
const QgsGeometry lineGeom 
)

Returns linear reference geometry.

Unlike the PostGIS function, this method always returns multipoint or 0 if no match (not geometry collection). Currently, the z-coordinates are considered to be the measures (no support for m-values in QGIS)

Definition at line 1214 of file qgsgeometryanalyzer.cpp.

◆ locateBetweenMeasures()

QgsGeometry * QgsGeometryAnalyzer::locateBetweenMeasures ( double  fromMeasure,
double  toMeasure,
const QgsGeometry lineGeom 
)

Returns linear reference geometry as a multiline (or 0 if no match).

Currently, the z-coordinates are considered to be the measures (no support for m-values in QGIS)

Definition at line 1173 of file qgsgeometryanalyzer.cpp.

◆ simplify()

bool QgsGeometryAnalyzer::simplify ( QgsVectorLayer layer,
const QString shapefileName,
double  tolerance,
bool  onlySelectedFeatures = false,
QProgressDialog p = nullptr 
)

Simplify vector layer using (a modified) Douglas-Peucker algorithm and write it to a new shape file.

Parameters
layerinput vector layer
shapefileNamepath to the output shp
tolerance(level of simplification)
onlySelectedFeaturesif true, only selected features are considered, else all the features
pprogress dialog (or 0 if no progress dialog is to be shown)

Definition at line 32 of file qgsgeometryanalyzer.cpp.


The documentation for this class was generated from the following files: