Hot answers tagged

38

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. What it seems like you need to do is define your layer so that it's as if those features don't exist. In ArcGIS this would usually be done using a Definition Query,...


38

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.


31

Nowadays (QGIS v3.x) Get the layer reference: layer = iface.activeLayer() Select features by expression: layer.selectByExpression( "\"ogc_fid\"=482" ) Before QGIS 2.16 Follow these steps: Get the layer reference: cLayer = iface.mapCanvas().currentLayer() Get a featureIterator from an expression: expr = QgsExpression( "\"ogc_fid\"=482" ) it = cLayer....


24

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 the filter of: QGIS 3.0+ (from thequerist in the comments): is_selected() QGIS 2.12-2.18: isselected( @layer_name ) Or QGIS 2.8: isselected( '...


21

In QGIS 2.12 I have been able to select records with the Select By Expression function and $geometry IS NULL You can see the selected objects in the attribute table (since they obviously won't appear on the map). This might work in earlier versions, and would save folks from scripting in Python, as per Jake's answer.


18

You may use the Feature Class To Feature Class python snippet. Here is the general syntax. FeatureClassToFeatureClass_conversion (in_features, out_path, out_name, {where_clause}, {field_mapping}, {config_keyword}) To output to a shapefile, make sure that your out_path is a folder (and not pointing within a file geodatabase), and that out_name has a *....


14

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 selection layer will break. There is no where clause in a selection layer. It is based on FIDset (the FIDs that were selected when you used 'Create layer ...


13

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 | 15 5 | 24 6 | 24 7 | 24 If you open the attribute table, you can find an epsilon symbol (in the figure below, the ...


13

Make selection color transparent by reducing opacity in Set Selection Color window. Settings menu > Options > Canvas & Legend > Selection color The same setting is available on a project-specific basis in the Project > Properties menu. You may need to restart QGIS to see the changes. Here are another few options for making the background visible ...


12

There are two expression functions (q1 and q3) which return %25 and %75 quartiles. You can use both in Select Features by Expression tool. Docs: q1: Returns the calculated first quartile from a field or expression. q3: Returns the calculated third quartile from a field or expression. $area > q1( $area ) and $area < q3( $area ) Different combinations ...


11

The best way I've understood how Create Layer from Selected Featuresis this reference that I came across Create a temporary layer to select features Creating a temporary layer allows you to do things, such as make selections, without affecting the original data source. This layer will not appear in the ArcCatalog contents, because it is created in-memory ...


11

To select from all layers at once, you need to install Multiple Layer Selection plugin from Plugins -> Manage and Install Plugins -> search for "Multiple Layer Selection" The Multiple Layer Selection plugin has two options: Multiple Selection by point, and Multiple Selection by Rectangle Use option 2 to select the point and the polygon from ...


10

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: selection = [ID for ID in selection if ID not in deselected] print(f"Selection: {selection}") else: # get newly selected IDs ...


9

The select features of visible layer has been integrated into QGIS and its toolbar. Just select a layer in the table of contents and click on this little icon: If this isn't the function you wanted than you might have to wait(or pay him) for the original plugins author to adapt the plugin for QGIS 2.0.


9

Some time ago I had a similar problem (How to change the symbology of selected features in QGIS). It seems that this features isn't available in QGIS 2.12 yet (https://hub.qgis.org/issues/12879), so you can achieve this effect using isselected function, available in Nathan's plugin qgsexpressionplus (https://github.com/NathanW2/qgsexpressionsplus). For ...


8

Also I common mistake I have made is not having the layer set as a selectable layer in ArcGIS. An easy fix for this is to right click on the layer in the Table Of Contents, chose "Selection", and then select "Make This The Only Selectable Layer". A better way to go would be to enable the the "Set Selectable Layers" tool somewhere in the customize menu. ...


8

You can use the floor function in your expression, like this: floor($id /24) IN (1,3,5,7,9,11,13,15,17,19,21) On a sample grid I've obtained this result with my own numbers (my grid has 13 columns per row): I've used: floor($id/13) IN (1,3,5,7,9) So, in general: floor($id / number_of_columns) IN (1, 3, 5, ..., 2*number_of_rows_to_be_selected - 1) To ...


8

If you open Project Properties there is an "Identify Layers" tab that allows you to turn on and off the layers that are identifiable, is that what you're after?


7

Instead of: "'ZIP' = '10004'" try this: '"ZIP" = ' + "'10004'" The reason that your original expression gives an empty output is because the string 'ZIP' is not the same as (equal to) the string '10004'.


7

You can do it in several different ways. Assuming you already have a selection, you can add new feature to your selection by: Select them interactivelly with any of the selections tool(Rectangle, Polygon, freehand), pressing "Ctrl" or "cmd" (Like jake already said). Take notice that if you select a already selected feature, it will be unselected; If you ...


7

create a new polygon layer, draw a single polygon that covers all your current polygons, then cut the newly drawn polygon based on all your existing polygons, then select all polygons from you current set that share a line segment with the newly drawn polygon using select by location and you're done ---Edited version much more efficient, based on comment----...


7

Edit: The first method I posted wouldn't work. This one should though. One straightforward way to do this would be to select everything you want to keep via Make Feature Layer with a where clause of X <> c. Then, use Copy Features to save the result.


7

You need a ST_GeomFromGeoJSON select * from points p where ST_Within( p.geom, ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[...]}') ) Edit: ST_Intersects works also (need to set SRID on GeoJSON, and transform): select row_to_json(t) from (select * from table where st_intersects( st_transform( st_setsrid( ...


7

Yes, it's possible, using the new Python function editor in 2.8 or later. For a good tutorial check out this youtube video Your existing expression will always show the value of field "LAENGE" for all features, this is working as expected. What you really want is an $is_selected() function which evaluates to True if the feature is selected, or False if it ...


7

The problem is that you're not using variables in your query. Instead you're using strings that happen to be the same as your variable names. What you want is: field_area = 'Area' minimum_area = 20 where_clause = '{} > {}'.format(arcpy.AddFieldDelimiters('input', field_area), minimum_area) arcpy.Select_analysis("input", "output", where_clause) Of ...


7

This is an easier alternative. layer = iface.activeLayer() expr = QgsExpression( "num_geometries( $geometry ) > 1" ) it = layer.getFeatures( QgsFeatureRequest( expr ) ) ids = [i.id() for i in it] Now you can know how many features are multi-part: print 'There are {} multipart features in this layer'.format(len(ids)) And even select multi-...


6

You probably already figured this out, but in case someone else comes across it, you can click the small selection icon to the right of the layer you want to make selectable (or not selectable). See the red arrow:


6

There are a few general ways to accomplish this: Use the select features tool (see first figure) Select by attributes manually (Right-click on layer > open attribute table) (highlighted in orange) Search by SQL (highlighted in red)


6

This worked for me on the QGIS Python Console layer = qgis.utils.iface.activeLayer() layer .selectByExpression(" \"ogc_fid\" = '{}' ".format(482))


6

This should work for a polygon layer (I've tested it in the QGIS Python console, QGIS v.2.8.1): from qgis.gui import QgsRubberBand from PyQt4.QtGui import QColor rbDict = {} # We need this to store the rbs we'll create layer = iface.activeLayer() # Create rubber bands for f in layer.getFeatures(): fId=f.id() rbDict[fId] = QgsRubberBand(iface.mapCanvas(...


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