Skip to main content
added 84 characters in body
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

TheSince QgsMapLayerRegistry has been removed, the QgsMapLayerRegistry in the @Joseph answer must be replaced by QgsProject (QgsMapLayerRegistry has been removed)QgsProject.

Now, answering the question:

from qgis.core import *
iface.mainWindow().blockSignals(True)
vlayer = QgsVectorLayer(dfx_file, 'layer_test', 'ogr') 
crs = vlayer.crs()
crs.createFromId(5347)  # Replace '5347' with whatever CRS id you want
vlayer.setCrs(crs)
QgsProject.instance().addMapLayer(vlayer)
iface.mainWindow().blockSignals(False)
from qgis.core import *

iface.mainWindow().blockSignals(True)
vlayer = QgsVectorLayer(dfx_file, 'layer_test', 'ogr') 
crs = vlayer.crs()
crs.createFromId(5347) # Replace '5347' with whatever CRS id you want
vlayer.setCrs(crs)
QgsProject.instance().addMapLayer(vlayer)
iface.mainWindow().blockSignals(False)

The QgsMapLayerRegistry in the @Joseph answer must be replaced by QgsProject (QgsMapLayerRegistry has been removed).

Now, answering the question:

from qgis.core import *
iface.mainWindow().blockSignals(True)
vlayer = QgsVectorLayer(dfx_file, 'layer_test', 'ogr') 
crs = vlayer.crs()
crs.createFromId(5347)  # Replace '5347' with whatever CRS id you want
vlayer.setCrs(crs)
QgsProject.instance().addMapLayer(vlayer)
iface.mainWindow().blockSignals(False)

Since QgsMapLayerRegistry has been removed, the QgsMapLayerRegistry in the @Joseph answer must be replaced by QgsProject.

Now, answering the question:

from qgis.core import *

iface.mainWindow().blockSignals(True)
vlayer = QgsVectorLayer(dfx_file, 'layer_test', 'ogr') 
crs = vlayer.crs()
crs.createFromId(5347) # Replace '5347' with whatever CRS id you want
vlayer.setCrs(crs)
QgsProject.instance().addMapLayer(vlayer)
iface.mainWindow().blockSignals(False)
added 62 characters in body
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

The QgsMapLayerRegistry in the @Joseph answer@Joseph answer must be replaced by QgsProject (QgsMapLayerRegistry has been removed).

Now, answering the question:

from qgis.core import *
iface.mainWindow().blockSignals(True)
vlayer = QgsVectorLayer(dfx_file, 'layer_test', 'ogr') 
crs = vlayer.crs()
crs.createFromId(5347)  # Replace '5347' with whatever CRS id you want
vlayer.setCrs(crs)
QgsProject.instance().addMapLayer(vlayer)
iface.mainWindow().blockSignals(False)

The QgsMapLayerRegistry in the @Joseph answer must be replaced by QgsProject (QgsMapLayerRegistry has been removed).

Now, answering the question:

from qgis.core import *
iface.mainWindow().blockSignals(True)
vlayer = QgsVectorLayer(dfx_file, 'layer_test', 'ogr') 
crs = vlayer.crs()
crs.createFromId(5347)  # Replace '5347' with whatever CRS id you want
vlayer.setCrs(crs)
QgsProject.instance().addMapLayer(vlayer)
iface.mainWindow().blockSignals(False)

The QgsMapLayerRegistry in the @Joseph answer must be replaced by QgsProject (QgsMapLayerRegistry has been removed).

Now, answering the question:

from qgis.core import *
iface.mainWindow().blockSignals(True)
vlayer = QgsVectorLayer(dfx_file, 'layer_test', 'ogr') 
crs = vlayer.crs()
crs.createFromId(5347)  # Replace '5347' with whatever CRS id you want
vlayer.setCrs(crs)
QgsProject.instance().addMapLayer(vlayer)
iface.mainWindow().blockSignals(False)
added 23 characters in body
Source Link

The QgsMapLayerRegistry in the @Joseph answer must be replaced by QgsProject ("QgsMapLayerRegistry"QgsMapLayerRegistry has been removed).

Now, answering the question:

from qgis.core import *
iface.mainWindow().blockSignals(True)
vlayer = QgsVectorLayer(dfx_file, 'layer_test', 'ogr') 
crs = vlayer.crs()
crs.createFromId(5347)  # WhateverReplace '5347' with whatever CRS id you want
vlayer.setCrs(crs)
QgsProject.instance().addMapLayer(vlayer)
iface.mainWindow().blockSignals(False)

The QgsMapLayerRegistry in the @Joseph answer must be replaced by QgsProject ("QgsMapLayerRegistry" has been removed).

Now, answering the question:

from qgis.core import *
iface.mainWindow().blockSignals(True)
vlayer = QgsVectorLayer(dfx_file, 'layer_test', 'ogr') 
crs = vlayer.crs()
crs.createFromId(5347)  # Whatever CRS you want
vlayer.setCrs(crs)
QgsProject.instance().addMapLayer(vlayer)
iface.mainWindow().blockSignals(False)

The QgsMapLayerRegistry in the @Joseph answer must be replaced by QgsProject (QgsMapLayerRegistry has been removed).

Now, answering the question:

from qgis.core import *
iface.mainWindow().blockSignals(True)
vlayer = QgsVectorLayer(dfx_file, 'layer_test', 'ogr') 
crs = vlayer.crs()
crs.createFromId(5347)  # Replace '5347' with whatever CRS id you want
vlayer.setCrs(crs)
QgsProject.instance().addMapLayer(vlayer)
iface.mainWindow().blockSignals(False)
edited body
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404
Loading
added 32 characters in body
Source Link
Loading
Source Link
Loading