Hot answers tagged

3

The $length expression function states that The length calculated by this function respects both the current project's ellipsoid setting and distance unit settings. For example, if an ellipsoid has been set for the project then the calculated length will be ellipsoidal, and if no ellipsoid is set then the calculated length will be planimetric. ...


2

You need to use string formatting in order to loop on each road type. Therefore, change the following line layer.selectByExpression('"RoadMntnc"= road', QgsVectorLayer.SetSelection) to layer.selectByExpression('"RoadMntnc"= \'{0}\''.format(road), QgsVectorLayer.SetSelection)


2

I figured out another solution (QGIS 3.4): startup.py from PyQt5.QtCore import QSettings,QStandardPaths from PyQt5.QtGui import QPixmap from PyQt5.QtWidgets import QLabel, QWidget, QSplashScreen,QApplication import os try: s = QSettings() s.setValue("PythonPlugins/BufferSelection",True) except: pass try: widgets= QApplication.allWidgets() ...


1

Use addMapLayer(layer,False), which will add a layer without showing it memlay = QgsVectorLayer("Point","myLayer", "memory") QgsProject.instance().addMapLayer(memlay, False) #False is the key sgroup.addLayer(memlay) Then you can simply add it to an existing group without cloning etc.


1

I had the same error with QGIS 3, by writing multiple times to a vector layer with "qgis:zonalstatistics" processing function. The layer wasn't in the registry: registryLayers = QgsProject.instance().mapLayers().keys() legendLayers = [ layer.layerId() for layer in QgsProject.instance().layerTreeRoot().findLayers() ] layersToRemove = set( registryLayers ) - ...


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