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
31 votes

Displaying only selected features on map in QGIS

This is now possible using just selections and a rule-based symbology. This requires the Expression Plus plugin (for QGIS 2.x. 3.0 has the functionality built in). Create a rule based symbology with ...
HeikkiVesanto's user avatar
30 votes

Displaying properties of GeoJSON in popup on Leaflet?

The line where you create and bind your popup should have been included in the onEachFeature option of your L.geoJSON factory. var layerGroup = L.geoJSON(data, { onEachFeature: function (feature, ...
ghybs's user avatar
  • 7,143
23 votes

Reading feature class in file geodatabase using R?

As already posted in this answer, this now also works very nicely with sf: require(sf) fc <- sf::st_read("C:/path/to/your/filegeodatabase.gdb", layer = "some_featureclass") But writing into a ...
Ratnanil's user avatar
  • 953
18 votes
Accepted

Updating text column of selected features in QGIS

make sure the layer is in edit mode (otherwise changes will not happen) Select features to change (however you like) then open attribute table select the attribute to change type in what you want it ...
Ian Turton's user avatar
  • 79.9k
18 votes
Accepted

Getting the bounding box for each feature in the source layer in QGIS

In the Processing Toolbox (Processing Tab > Toolbox or Ctrl+Alt+T) you will find a tool called Bounding boxes. This will achieve what you want. If your layer contains some multipart features you ...
Cushen's user avatar
  • 2,843
17 votes

Applying categorized symbol to each feature using PyQGIS

For those who'd like to try the code above for the PyQGIS3 version, here is my adaptation (it works for the 'active layer' if run from the console ...). # provide file name index and field's unique ...
A. Jean's user avatar
  • 301
17 votes
Accepted

Copying & pasting multiple values from one feature to other features in the same layer in QGIS

There is the AttributePainter plugin (https://plugins.qgis.org/plugins/attributePainter/) for this. Usage: Click on Pick source feature and select a sample feature on the map. On the table, a ...
Kadir Şahbaz's user avatar
16 votes
Accepted

Can someone help me identify this part of the map?

Here you find the map including the legend. The legend is in German, but I am German, so I tried to translate it as precise as possible. I think (and please @Giancarlo correct me, if you disagree): ...
Iris's user avatar
  • 894
16 votes
Accepted

'Could not load source layer for INPUT: layer not found' error when running QGIS algorithm on selected features using PyQGIS

You need add the layer to project. For add without showing it use: QgsProject.instance().addMapLayer(layer1, False) Example using only one layer: layer1 = QgsVectorLayer(r"C:\test\grassland....
Fran Raga's user avatar
  • 7,780
16 votes
Accepted

Getting dictionary for each feature with their attribute values using PyQGIS

The QgsJsonUtils class has exportAttributes method for getting attributes as a dict. Solution 1: Making a dictionary including feature "id" as key, attributes map as value: {feature1.id: {...
Kadir Şahbaz's user avatar
14 votes

Getting number of features in attribute table using PyQGIS

Yes, there is a direct way to access the number of rows of your attribute table. Just call featureCount() method from your layer object: num_of_features = layer.featureCount()
Germán Carrillo's user avatar
14 votes
Accepted

OpenLayers: Get Coordinates of drawn features

The drawn feature are added to the layer named vector. See draw interactions constructors. // Get the array of features var features = vector.getSource().getFeatures(); // Go through this array and ...
oterral's user avatar
  • 1,129
14 votes
Accepted

Tying visibility of features to zoom level by attribute in QGIS

You can change the style to be rule-based (it will preserve the classes if a categorized style was previously set), and there you can control the display scale of each class/rule.
JGH's user avatar
  • 39.8k
13 votes
Accepted

Counting number of selected features in QGIS

Look at the header of the attribute table, it tells you the total number of objects in tables, as well as the filtered and selected ones.
Pierre Vivet's user avatar
13 votes
Accepted

Is there a maximum number of features that QGIS can save into a shapefile?

Officially, .shp and .dbf files are limited to 2GB. Using GDAL Shapefile driver this can be exceeded, but as stated on this site, this is not recommended due to compatibility issues (See point #Size ...
MrXsquared's user avatar
  • 32.6k
13 votes

Deleting features in PyQGIS?

Decide either to work with the data provider or the layer, not both Working directly on the layer has the advantage, that all internals of QGIS are notified about changes/deletions, whereas changes ...
Matthias Kuhn's user avatar
13 votes

Determining number of vertices of selected object in QGIS 3

You can use the following script in QGIS Python Editor. Select a layer, run the script and select a feature. def n_vertices(selected, _, __): n = len(selected) if n == 1: g = ...
Kadir Şahbaz's user avatar
13 votes
Accepted

Selecting multiple features by ID-attribute from list using PyQGIS

Use this way (without for loop): id_list = [1, 2, 5] layer.selectByExpression("id in {}".format(tuple(id_list)))
Kadir Şahbaz's user avatar
12 votes
Accepted

Applying categorized symbol to each feature using PyQGIS

To draw a layer with a categorized renderer you first should create appropriate categories. A category needs value, symbol, and label. If you know the values at design time you may define these 3 ...
Detlev's user avatar
  • 4,538
12 votes
Accepted

Merging spatially separated polygons into one feature in QGIS

Check the corresponding geoalgorithm in the Processing Toolbox (Ctrl+Shift+T). For QGIS 3 : "Promote to multipart" For QGIS 2 : "Singleparts to multipart"
eclipsed_by_the_moon's user avatar
12 votes
Accepted

Creating Virtual layer in QGIS that shows only features in extent

The trick is to create a function that access QGIS graphical interface, and that is piped to the query of the virtual layer. Open a function editor (from anywhere, including from field calculator) ...
JGH's user avatar
  • 39.8k
12 votes
Accepted

Getting ordered list of IDs of selected features using PyQGIS

Use this script: selection = [] def selection_changed(selected, deselected, clearAndSelect): global selection # If the user deselects feature(s), remove ID's from list if deselected: ...
Kadir Şahbaz's user avatar
12 votes
Accepted

Determining number of vertices of selected object in QGIS 3

num_points($geometry) returns the number of vertices of the current feature.
Erik's user avatar
  • 15.5k
11 votes

Displaying properties of GeoJSON in popup on Leaflet?

Build a simple popup content for any properties in a simple way, in one line: var layer = L.geoJSON(data, { onEachFeature: function (f, l) { l.bindPopup('<pre>'+JSON.stringify(f.properties,...
stefcud's user avatar
  • 396
11 votes
Accepted

Feature Count in Legend (QGIS 2.18.2)

You may try a right click on your layer and then chose to Show Feature Count (green on figure):
swiss_knight's user avatar
  • 9,556
11 votes
Accepted

Running QGIS algorithm with selected features from layer using PyQGIS

For only selected feature use the QgsProcessingFeatureSourceDefinition class. Code below with the input of selected features only: import processing input_vlayer = 'Some path' intersect_vlayer = '...
Fran Raga's user avatar
  • 7,780
11 votes

Getting dictionary for each feature with their attribute values using PyQGIS

The snippet below should help you. It just prints a dictionary for each feature to the console, but you could do something else with the feature attribute dictionaries if you wanted. from qgis.utils ...
Ben W's user avatar
  • 20.2k
11 votes
Accepted

Sorting records by attribute in shapefile using PyShp

The script you need: features = shapefile.Reader("c:/data/cities.shp").shapeRecords() features.sort(key=lambda feat: feat.record["NAME"]) # or ["POPULATION"] ...
Kadir Şahbaz's user avatar
11 votes

Tying visibility of features to zoom level by attribute in QGIS

Get ready for the probably most useful option when it comes to symbology: data defined override My suggestion: For each of your classes, set the line type based on your current scale, e.g. if(@...
Erik's user avatar
  • 15.5k

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