I do QGIS based application, I need to implement the ability to modify the geometry of vector layers in manual mode (editing nodes), how to do it?
QGIS Vector Layer Class
You will need to become familiar with layer attributes and features. The QGIS Vector Layer Class Reference will be a good source of information.
The basic workflow will be to:
- Select the layer via the
- Get some or all features in the layer with the getFeatures()
- Work with the feature geometry (with insertVertex(), moveVertex(), deleteVertex(), etc.
# Load a vector layer layer = QgsVectorLayer('/path/to/layer.shp',"Legend Name", "ogr") # E.g. Set up a rectangle for use as a bounding box query filter_rectangle = QgsRectangle(-100, 50, -130, 60) # Create a feature request object feature_query = QgsFeatureRequest().setFilterRect(filter_rectangle) # Get a set of features for manipulation, using the feature query object features = layer.getFeatures(feature_query) # You can now iterate through the features for feature in features: # Do something
The above code was adapted from the PyQGIS Programmer's Guide.
You can download the Digitizing Tools plugin. Once enabled, select Toggle Editing then you can play around with editing geometries, shapes etc with the available functions.