Hot answers tagged

56 votes
Accepted

Filtering features in other layers of QGIS Atlas

Indeed, you need to use rule-based symbology to achieve what you want. You need to create a rule for what you want to show, and ELSE rule for all others. In the ELSE rule, deselect the symbol ...
Alexandre Neto's user avatar
45 votes

Change style properties of several layers simultaneously?

This works for QGIS 3.4 => Create a group of all the layers you want to have the same style Edit the style of one of the layers in the group to your liking Right-click the correctly styled layer; '...
GISinHelsinki's user avatar
31 votes
Accepted

What are the min and max values of Map.addLayer on Google Earth Engine?

Let's start from the beginning. How satellite remote sensing work Satellites carry out sensors that can measure radiance at different wavelengths (it depends on the sensor) For example, Landsat ...
Rodrigo E. Principe's user avatar
27 votes

Getting list of layer names using PyQGIS

Since version 3, QgsMapLayerRegistry funcionalities have been moved to QgsProject: https://qgis.org/api/api_break.html Update for QGIS3.x: from qgis.core import QgsProject names = [layer.name() for ...
RafDouglas C. Tommasi's user avatar
25 votes

Iterating over map layers using PyQGIS

For QGIS 3, QgsMapLayerRegistry's functionality has been moved to QgsProject. So, for iterating over map layers, you should use that structure: layers = QgsProject.instance().mapLayers() ....
Kadir Şahbaz's user avatar
25 votes
Accepted

Getting field names of layer using PyQGIS

To get field names with fields() method or other field properties (length, type, comment, ...) you can use: field_names = [field.name() for field in layer.fields()] # ['id', 'attr1', 'attr2', 'attr3'] ...
Kadir Şahbaz's user avatar
24 votes
Accepted

Setting layer transparency in QGIS 3

You have to click on the layer rendering arrow (see the bottom of your second image) to access the slider and other option. in QGIS 2 it was on by default, in QGIS 3 it's off by default...
J.R's user avatar
  • 14.5k
22 votes

Duplicating layer in memory using PyQGIS

In QGIS 3 you can make a copy of a layer without saving any reference to the parent layer in this way: layer.selectAll() clone_layer = processing.run("native:saveselectedfeatures", {'INPUT': ...
Leo Cardona's user avatar
  • 1,343
22 votes
Accepted

Making layer or group private/hidden/invisible in Layers Panel of QGIS

Just to clarify, private/hidden layers/groups will not appear in the Layers Panel, but they can still be seen in the canvas or used in joins/relations with other layers. Native approach (QGIS API) You ...
Germán Carrillo's user avatar
21 votes

Setting layer transparency in QGIS 3

As an alternative option, you can open Legend tab and select Opacity slider widget. It will add an opacity slider in the Layers panel.
Kazuhito's user avatar
  • 30.4k
21 votes
Accepted

Showing the number of currently selected layers in QGIS

You can use this script. It adds a toolbar as seen in the image and shows how many layers are selected. label = QLabel("Selected Layers Count:") count = QLabel() tree_view = iface....
Kadir Şahbaz's user avatar
20 votes
Accepted

Duplicating layer in memory using PyQGIS

The following code works for me from both the Python Console and plugin. It takes the features from the source input layer and copies the attributes to a memory layer (in this case, a polygon layer ...
Joseph's user avatar
  • 75k
19 votes
Accepted

Activating layer by its name in PyQGIS

TL;DR To get all features of a layer by the layer name you do not need to activate it. Just use name = 'counties' layer = QgsProject.instance().mapLayersByName( name )[0] poles = layer.getFeatures() ...
Matthias Kuhn's user avatar
19 votes

Understanding Coordinate Reference System of QGIS Project and Layer

Short answer: there is project CRS and layer CRS: You can more or less freely choose any project CRS, QGIS handles the rest automatically. You can't "set" another CRS for your layer (your ...
Babel's user avatar
  • 63.1k
18 votes

Using layer loadstart & loadend events in OpenLayers 3?

In ol3 version 3.10.0 things have changed. So is more clear than older versions but still more complicated than ol2. So for TILE (ol.layer.Tile) layers your code snip should look like: //declare the ...
pavlos's user avatar
  • 3,538
18 votes
Accepted

Check if layer exists in QGIS Project using PyQGIS

len(QgsMapLayerRegistry.instance().mapLayersByName('the_Map_Layer_in_question')) != 0 Trueif layer exists, otherwise False
Detlev's user avatar
  • 4,538
17 votes
Accepted

Symbols above labels in map QGIS

I don't think there is a way to do this in the map canvas itself. The labels will always be on top at least in QGIS 2.x. But for the print composer, you can work with two maps. They should be in the ...
HeikkiVesanto's user avatar
16 votes
Accepted

Reprojecting layer using PyQGIS

You can use processing algorithm native:reprojectlayer. Example: lyr = iface.activeLayer() parameter = { 'INPUT': lyr, 'TARGET_CRS': 'EPSG:4326', 'OUTPUT': 'memory:Reprojected' } result = ...
Fran Raga's user avatar
  • 7,780
16 votes
Accepted

Change vector layer symbology PyQGIS 3?

The easiest for me would be to check the properties of the symbology layer which contains symbol properties affecting the whole layer: dir(symbol) >>>['DynamicRotation', 'Fill', 'Hybrid', '...
Joseph's user avatar
  • 75k
15 votes
Accepted

Adding Properties to a feature in Google Earth Engine

Yes, you can use the feature.set()option which Feature Overview covers with these examples: // Make a feature and set some properties. var feature = ee.Feature(ee.Geometry.Point([-122.22599, 37.17605]...
whyzar's user avatar
  • 12k
15 votes

Getting field names of layer using PyQGIS

List field names with dataProvider() method from qgis.utils import iface # get active layer if not already set layer = iface.activeLayer() prov = layer.dataProvider() field_names = [field.name() ...
grego's user avatar
  • 1,003
15 votes

Turning on/off ALL selected layers in QGIS

In the Layer pannel, there is an icon in form of an eye : Manage Map Themes (documentation) : By clicking on it, you can see the option for display / mask the selected layers. You can also go to the ...
J. Monticolo's user avatar
  • 15.5k
15 votes

Showing the number of currently selected layers in QGIS

To extend the great solution by @Kadir Şahbaz, you could do something like this to get a count per group: p = QgsProject.instance() root = p.layerTreeRoot() view = iface.layerTreeView() ## TOOLBAR tb ...
Matt's user avatar
  • 14.2k
14 votes

Merging multiple vector layers to one layer using QGIS

In the meantime, a tool called "Merge vector layers" has been added to QGIS under Vector > Data Management Tools > Merge Vector Layers or under Vector general in the Processing Toolbox ...
stopopol's user avatar
  • 283
14 votes

Setting layer visibility in QGIS Python API?

For QGIS 3, you have to use: QgsProject.instance().layerTreeRoot().findLayer(layer_id).setItemVisibilityChecked(False) or to be safe node = QgsProject.instance().layerTreeRoot().findLayer(layer_id)...
Denis Rouzaud's user avatar
14 votes
Accepted

Is it possible to set different scale dependent visibility for one layer classifications?

You need to use Rule based style to set the scale for primary, secondary and tertiary network, as you can see below (but with different data): You can double-click each styled label to get more ...
ahmadhanb's user avatar
  • 40.3k
14 votes
Accepted

Editing shp layers style simultaneously in QGIS?

With a little help from Python, we could set the border width for all layers in your "State" group to a specific value (e.g. 0.16 as shown in your image). Try testing the following in the Python ...
Joseph's user avatar
  • 75k
14 votes
Accepted

Create Layer from Selected Features tool: How is the list of features stored?

Create Layer From Selected Features DOES NOT create a DYNAMIC layer. The resulting layer is not dynamic at all. It is based on an FIDset. If you change the source data, the FIDs will change and your ...
jbalk's user avatar
  • 7,275
14 votes
Accepted

Selecting layers in group using PyQGIS

You can use the following lines: newtable = QgsVectorLayer("None", "Results", "memory") provider = newtable.dataProvider() provider.addAttributes([QgsField('Layername', ...
Kadir Şahbaz's user avatar
13 votes

Georeferencing vector layer with control points using QGIS?

I recommend the Vector Bender plugin for QGIS. I tried it and it works fine and is user friendly. Depending on amount of pair of points that you define, you can either do: translations: translation ...
ZKB's user avatar
  • 1,152

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