For a project of mine, I'd like to solve a spatial analysis using QGIS 2.8.
Until now, I have never automated anything GIS-related except for some rather easy steps in ArcGIS using the ModelBuilder.
This is what's supposed to be done:
- Select all polygons from shapefile A that overlap a similar shapefile B (-> Select by location)
- Extract selected polygons from A creating shapefile C, B serves as clip feature (-> Clip)
- Add a columns reading area for each of the extracted features of C (-> Add geometry columns)
- Calculating the percentage of each feature's (C) area in regard to all extracted polygons (= sum), store this information in a new column (I'm actually not sure how to do this except manually using the individual .dbf-file, the GroupStats plugin works fine but cannot write the newly calculated information in the attribute table)
- Calculate a new value in a new field in C's attribute table based on the area's percentage (see 4) and an existing value (derived from A, see 2) (-> Field Calculator)
- Summing up the calculate values (see 5) in a new field (-> Field Calculator)
- Merge all selected polygons from C (-> Editor or Dissolve) (see 2)
For me, the major problem is that this workflow needs to be done some hundred times at least. Therefore, if this can be easily done using the Modeler, the Python console or something (my Python knowledge is somewhat limited but not entirely non-existent), I am willing to dedicate some time to delve into tutorials or instruction manuals in order to be better off next time.
Here's my latest model. How can I perform the fourth task?
Trying to add underdark's script from file resulted in this configuration error message:
Traceback (most recent call last): File "/home/tjk/.qgis2/python/plugins/processing/gui/ProcessingToolbox.py", line 221, in executeAlgorithm action.execute() File "/home/tjk/.qgis2/python/plugins/processing/script/AddScriptFromFileAction.py", line 45, in execute settings = QSettings(QSettings.NativeFormat, QSettings.UserScope, 'QuantumGIS', 'QGis') NameError: global name 'QSettings' is not defined
I tried the solution to https://stackoverflow.com/questions/18769383/qgis-preferences-in-a-python-plugin but nothing happened.
Shouldn't QSettings be defined automatically while I'm using the software, saving my personal preferences?