Tag Info

New answers tagged

2

If I got you right, you can achieve that by running a Python script. You can follow this workflow: Open QGIS, load a vector layer and select it (activate it) in the ToC. Observe this function: def selectByExpression(): cLayer = iface.mapCanvas().currentLayer() expr = QgsExpression( "\"COD_DANE\"=13" ) it = cLayer.getFeatures( ...


1

I've included a screenshot to show where the function is in the Configure shortcuts option:


2

Follow these steps: Get the layer reference: cLayer = iface.mapCanvas().currentLayer() Get a featureIterator from an expression: expr = QgsExpression( "\"ogc_fid\"=482" ) it = cLayer.getFeatures( QgsFeatureRequest( expr ) ) Build a list of feature Ids from the result obtained in 2.: ids = [i.id() for i in it] Select features with the ids obtained in ...


2

Try this: canvas.zoomToSelected( cLayer ) The zoomToSelected method accepts a layer as argument, see QgsMapCanvas. However, I've noticed it should also work without argument. That's strange.


1

Slight variation on @blah238's really great answer. Updated with arcpy.da goodness with appropriate tips'o'the cap documented: The relevant function: def getOIDChunks(inputFC, oidfield, groupsize): oids = [] oidchunks = [] #from https://arcpy.wordpress.com/2012/02/01/create-a-list-of-unique-field-values/ with ...


0

You could pass the entire layer by parameter to createSelector function. I mean: createSelector(layers[1]) And then, in the function, you could select the sublayer that you really want depending on the clicked that you receive.



Top 50 recent answers are included