I need to select polygons and change some attributes in a shapefile. I'm using Quantum GIS – I select the polygon, open attribute table and edit the attributes I want. I know there must be an easier and faster way to do this. I was thinking in some tool which when the feature is selectd pop-up a form with the respective attributes and lets you edit them.
[GIS] ny tool/plugin for QGIS to easily select feature and edit attributes
editingqgis
Related Solutions
Users can choose from one of the following editing widgets:
- Line edit – a simple edit box
- Classification – displays a combo box with the values used for “unique value” classification (symbology tab)
- Range – allows numeric values within a given range, the widget can be either slider or spin box
- Unique values
- editable – displays a line edit widget with auto-completion suggesting values already used in the attribute table
- not editable – displays a combo box with already used values
- File name – adds a file chooser dialog
- Value map – shows a combo box with predefined description/value items
- Enumeration – a combo box with values that can be used within the columns type
- Immutable – read-only
- Hidden – makes the attribute invisible for the user
- Checkbox – a checkbox with customizable representation for both checked and unchecked state
- Text edit – an edit box that allow multiple input lines
- Calendar – a calendar widget to input dates
[Source: http://underdark.wordpress.com/2010/07/28/customized-attribute-editing-in-qgis-1-5/]
Although you're asking for an answer related to value map combo-boxes, I thought to provide an alternative where you could use the following code to read the values in the first row for each column and copy it for each of the attributes. Select the layer in QGIS and copy/paste the code into the Python Console (Plugins -> Python Console
or Ctrl + Alt + P):
layer = qgis.utils.iface.activeLayer()
layer.startEditing()
for field in layer.pendingFields():
name = field.name()
request = QgsFeatureRequest().setFilterFid(0)
feat = layer.getFeatures(request).next()
result = feat[name]
for feature in layer.getFeatures():
feature[name] = result
layer.updateFeature(feature)
This is not automated, which is what you seem to be asking for. But I hope it helps a little anyway! Tested this on QGIS 2.8.2-Wien.
Update:
If you want to run the above script in the graphical modeler, first select the Create new script tool from Processing Toolbox -> Scripts
. Note you said 7 columns but gave 8 :). Then insert the following:
##Copy attributes from first row=name
##Layer=vector
import qgis
from qgis.core import *
layer = processing.getObject(input)
layer.startEditing()
for field in layer.pendingFields():
name = field.name()
request = QgsFeatureRequest().setFilterFid(0)
feat = layer.getFeatures(request).next()
result = feat[name]
for feature in layer.getFeatures():
if name == 'ALT_0':
feature[name] = result
layer.updateFeature(feature)
if name == 'ALT_1':
feature[name] = result
layer.updateFeature(feature)
if name == 'ALT_2':
feature[name] = result
layer.updateFeature(feature)
if name == 'ALT_3':
feature[name] = result
layer.updateFeature(feature)
if name == 'ALT_4':
feature[name] = result
layer.updateFeature(feature)
if name == 'ALT_5':
feature[name] = result
layer.updateFeature(feature)
if name == 'ALT_Ideale':
feature[name] = result
layer.updateFeature(feature)
if name == 'ALT_propos':
feature[name] = result
layer.updateFeature(feature)
Also note that I purposely did not save the changes just incase there's a mistake. If you want the script to save the changes, use the layer.commitChanges()
code at the end of the script outside all the for
loops.
I tested this and it seems to work so hopefully it will for you too =)
Best Answer
The "Identify" tool will let you do this. There's a setting under Settings > Options > Map Tools tab > Open Feature Form, if a single feature is identified. Then just make sure your layer is editable, and click the feature with the identify tool.