Hot answers tagged

7

You can use a script like this: layers = QgsProject.instance().mapLayers().values() for layer in layers: # get the first feature's UNIT_NAME value name = layer.getFeature(0)["UNIT_NAME"] layer.setName(name) Note: The script changes the name of the single layer that has 72 categories, too, if it exists in Layers panel. So you can add ...


5

You can use select by expression to select features on the same layer using the expression get_feature. The expression in this case is (see screenshot where the labels show the valule of the Seeding_Ra attribute for each polygon): overlaps( geometry ( get_feature ( @layer, 'Seeding_Ra', 33500 ) ), ...


4

So extending Kadir's answer, because I did not want all layers to be renamed, just those that got assigned names with a specific string through affine transform, I came up with the following, which worked nicely. import re RES_STRING='Palinspastic' STRING=re.compile(RES_STRING) layers = QgsProject.instance().mapLayers().values() for layer in layers: ...


2

The quickest way without opening the python console would be to do the following: run 'split vector layer' which creates a separate file for each of your vector features. Make sure to select an output directory. Then open all the vector files in qgis. now run 'clip raster by mask layer' and click on 'Run as Batch Process...' button in the bottom left hand ...


2

You can look at QGIS source code to find how it is done by QGIS developers. For instance, look at this example: self.addParameter( QgsProcessingParameterRasterLayer( self.INPUT_A, self.tr('Input layer A'), optional=False)) As usual, you can find the accepted arguments in the QGIS API docs.


1

I guess they have not disappeared: I think it is (just) an "alignment" trouble. I have something almost like this... If you expand the layer's panel on the right, you will probably see both your symbols and their names (actually, a little part of your symbols are visible in your screenshot), but in a "centered" way in a too large column, ...


1

You cant delete values in a raster but you can set them to no data. Set values <0.31 to -5 and all other to the ndvi raster values using Raster calculator: ("ndvi@1"<0.31)*-5 + ("ndvi@1">=0.31)*"ndvi@1" Translate and set no data value to -5 Result: (See: How to set all pixels with value <= 0 to "nodata" ...


1

You should keep the value returned by L.control.layers(...): var controls = L.control.layers(baseLayers, overlays, options).addTo(map); Now you can call map.removeControl(controls); and if you should want to add them back in again later on: map.addControl(controls);


Only top voted, non community-wiki answers of a minimum length are eligible