I'm loading a sqlite db into the current project of qgis with a plugin. The standard CRS is EPSG:4326, however i want the canvas to be set at EPSG:3857. When running one of the 2 codes in the console, it works correctly.
After running this code:
# Settign the CRS of the data set option 1 print('setting CRS to EPSG 3857') QgsProject.instance().setCrs(QgsCoordinateReferenceSystem(3857))
I can see a very quick change of the CRS code in the right lower corner of qgis. So i gues it changes to EPSG:3857 but it changes back to EPSG:4326. But when i reload the layer again (so by now there are 2 the same sqlite layers in the toc) it changes to the correct EPS:3857 CRS.
The code below from:
# Settign the CRS of the data set option 1 canvas = self.iface.mapCanvas() selectedcrs = "EPSG:3857" target_crs = QgsCoordinateReferenceSystem() target_crs.createFromUserInput(selectedcrs) canvas.setDestinationCrs(target_crs)
With this code the CRS is correct, EPSG:3857, but in the lower right corner the label states the wrong CRS code. EPSG:4326 in stead of EPSG:3857. The data is for sure EPSG:3857.
Main question: how do i load the sqlte db into the current project with the correct CRS?