It works when I specify the layer and set auto refresh:
layer = QgsProject.instance().mapLayersByName("my_layer_name")
For Oracle it takes too much time for the visual part, so I interact with spatialite in QGis, but I make my SQL statements on the two DB in parallel.
If you recall from your previous question, the method iface.addRasterLayer() takes 2 string arguments- the file path and layer name as parameters. You are passing it a raster layer object, hence the error is telling you that argument 1 has the unexpected type 'QgsRasterLayer'.
You can use the addMapLayer() method which belongs to the QgsProject class ...
SQL queries are really optimal but I offer you an alternative that will create a layer of gps points for each stop.
My starting layers
# Identification of gps layer
gps = QgsProject.instance().mapLayersByName("gps")
# Identification of stops layer
stops = QgsProject.instance().mapLayersByName("stops")
# List : Field with unique identifiers in ...
From DB Manager > Virtual Layers > SQL Window, you can run the following query (replace the tables and fields names with real ones) :
bus_stops.id, -- change here the field name id with identifier bus stop field
MIN(gps.time) AS bus_entered, -- change here the field name time for the gps field with time
MAX(gps.time) AS bus_left -- same here
With QGIS 3.10, you can duplicate your layer (polyline or polygon), go in its symbology, choose Geometry generator with Point / Multi-Point and paste this code :
5, --treshold to modify
Interesting question! I couldn't find any native signal emitted when an attribute table is opened or closed so I would call this solution a fairly inelegant workaround but it seems to work well enough. I found that QApplication has a focusChanged(old, new) signal which is emitted whenever the widget focus changes e.g. opening/ closing dialogs or clicking ...
You can use the qgis batch file as a template.
SET PyScripter="C:\Program Files\PyScripter\PyScripter.exe"
rem Set VSI cache to be ...
I've found a temporary solution:
layer = QgsProject.instance().mapLayersByName("LAYER_NAME")
attr_table = iface.showAttributeTable(layer)
table = attr_table.findChildren(QTableView)
""" zooms to feature when clicking FID field """
x = item.data() # get cell value
ID = list(layer.getFeatures('"FID" = ' + x))...
You're confusing a feature with a vector layer.
A feature is a row on a vector layer that may contain attributes and geometry.
A vector layer is a set of features that represent "the same kind of data", like a set of roads.
(Im being really simplistic with this explanation, please look more into it)
Now, assuming that you want the bounding box of all ...
As I wrote in the comment, I obtained something that works, activating the pan tool after the editing. I'm not sure if it is the correct method.
I'm writing only the added code:
def __init__(self, dlg, psrid, iface, tt, lab, lyr):
I've put together a script using bits from @Ben W's answer as well as from this answer this answer to a different question.
This takes the following inputs:
Number of Classes (number_classes)
Filed to use in the ramp (fld)
Existing Color Ramp (colorRampNumber)
Optional Alternative: user specified start and end colors to use for a custom color ramp
I have been through the same experience before, and (I may be wrong) but as far as I am aware, it is not possible to programmatically set a default color ramp and have it automatically applied. As you discovered, doing setSourceColorRamp() just sets that color ramp in the symbology dialog- it doesn't apply it to the renderer range symbols.
You have to ...
If it helps, to read the searchable and identifiable, we can use:
searchable = bool(QgsMapLayer.LayerFlag(layer.flags()) & 4)
identifiable = bool(QgsMapLayer.LayerFlag(layer.flags()) & 1)
This one is from the docs, and as mentioned there, it should refresh the query from your database, too.
Just define separate class methods in your main plugin class and connect them to different buttons in your UI tabs. For example, if you have buttons with object names like ok_btn_1 and ok_btn_2, in the initGui method of your main plugin file, connect the clicked signal to the methods which contain the 'processes' you want to run.
You can get the list of field names in the order you have arranged them (using the Drag and drop designer) in this way:
qgis_layer = iface.activeLayer()
edit_form_config = qgis_layer.editFormConfig()
root_container = edit_form_config.invisibleRootContainer()
for field_editor in root_container.findElements(QgsAttributeEditorElement.AeTypeField):