NameError: name 'QgsMapLayerRegistry' is not defined
Asked Answered
L

1

7

I am using Qgis 3.4.9. How can i fix To fix the error: NameError: global name 'QgsMapLayerRegistry' is not defined.

from qgis.core import QgsMapLayerRegistry Is not working in Qgis 3.4.9

QgsMapLayerRegistry.instance().addMapLayer(point_layer)
Longerich answered 31/10, 2019 at 6:45 Comment(0)
L
17

QgsMapLayerRegistry: Its functionality has been moved to QgsProject.

Syntax:

QgsProject.instance().addMapLayer(your_Qgs_whaterver_Layer)

Example:

QgsProject.instance().addMapLayer(point_layer)
Longerich answered 31/10, 2019 at 7:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.