I'm writing a plugin which will create a new virtual layer containing points. I know the CRS of the new layer, as it is the same as the layer I am using for input. I would like to specify the CRS in code but the CRS selector dialog pops up when I create the layer. I would like to suppress that dialog so that something like this will work.
def createVirtualLayer(self):
self.vl = QgsVectorLayer("Point","block_labels", "memory")
self.vl.setCrs(self.layer.crs())
self.vl = QgsVectorLayer("Point?crs=EPSG:4386", "block_labels", "memory")as described in these posts: How to avoid the CRS Dialog when creating a vector layer memory? and “CRS selector” dialog after running a script :) – Joseph Jun 29 '16 at 08:30