53 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 ...
user avatar
47 votes

Reading feature class in file geodatabase using R?

You can use rgdal to access feature classes in Esri file geodatabases. require(rgdal) # The input file geodatabase fgdb <- "C:/path/to/your/filegeodatabase.gdb" # List all feature classes in a ...
user avatar
  • 50.2k
47 votes
Accepted

How to select features containing specific text string using an expression in QGIS

You just gotta use the LIKE operator. For example, "TITLE" LIKE '%MINERAL CLAIM%' The % symbol acts like a wildcard. LIKE is case-sensitive, whereas ILIKE is not.
user avatar
  • 9,901
40 votes
Accepted

Displaying only selected features on map in QGIS

Kadeem's answer will prevent your features from being visible, but they will still be present, if you are trying to identify an individual ship track you may click an invisible feature by mistake. ...
user avatar
  • 12k
36 votes
Accepted

setStyle() function for GeoJSON features - Leaflet

This works without needing to remove the layer and recreate a new one as described above: geojson_layer.eachLayer(function (layer) { if(layer.feature.properties.NAME == 'feature 1') { ...
user avatar
  • 496
30 votes
Accepted

Changing the value of attribute using QgsFeature in PyQGIS

Answering your two questions: You can change your feature values from the layer object, no need to access the dataProvider(). Yes, you can use the iterator in a for loop (that's what iterators are ...
user avatar
29 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, ...
user avatar
  • 6,823
26 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 ...
user avatar
23 votes
Accepted

Deleting selected features using PyQGIS

You can loop over the iterator and get the id() for every feature in it: with edit(layer): # build a request to filter the features based on an attribute request = QgsFeatureRequest()....
user avatar
20 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 ...
user avatar
  • 823
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): ...
user avatar
  • 874
16 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 ...
user avatar
  • 74.6k
15 votes

Zooming to feature in QGIS?

Sure it is. Depending on what you need: zoom to whole layer right click on layer in Layers list and first item is "Zoom to layer" zoom to selected feature(s) select feature in map and click on ...
user avatar
  • 9,186
14 votes

Displaying only selected features on map in QGIS

Kristina, I assume there is an attribute in your table which allows you to identify a single track? For example: point_id | track_id ------------+------------ 1 | 15 2 | ...
user avatar
  • 545
14 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 ...
user avatar
  • 161
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 ...
user avatar
  • 1,084
14 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 ...
user avatar
  • 1,603
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.
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 = ...
user avatar
13 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.
user avatar
  • 34.2k
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)))
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 ...
user avatar
  • 4,390
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"
user avatar
12 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 ...
user avatar
  • 24.5k
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) ...
user avatar
  • 34.2k
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: ...
user avatar
12 votes
Accepted

PyQGIS getting dictionary for each feature of layer with their attribute values

QgsJsonUtils class has exportAttributes method for getting attributes as dict. Solution 1: Making a dictionary including feature id as key, attributes map as value: {feature1.id: {attr1: value, attr2: ...
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.
user avatar
  • 12.4k
11 votes

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):
user avatar
  • 6,698
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"] ...
user avatar

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