Monday, 1 August 2016

qgis - Applying field calculator for multiple layers at once


Is there a way to apply field calculator for multiple layers at once?


For instance, I have 80 layers as the picture shown below. If I want to apply $area for all the layers, is there a quicker way to do it except manually creating 'area' field?


enter image description here


this is how it looks after applying recommendation using pyqgis enter image description here



Answer



Other solution but it will make a new layer with the result and will not modify your current layers.


The steps : First use merge vector layers and select all the layers. This will merge all your vector layer in one new layer and add two fields "layer" with the source layer name and "path" with the source layer path. Then you can make your new field "area" to store $area.


Then if you want back your 80 layers you can use split vector layers based on "layer" field.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...