[QGIS-Developer] setDataSourceUri() not working

Raymond Nijssen r.nijssen at terglobo.nl
Thu Dec 8 23:19:01 PST 2022


Thanks Andrea, but that doesn't seem to exist:

AttributeError: 'QgsVectorLayer' object has no attribute 'setDataSourceUri'

Raymond


On 08-12-2022 19:42, Andrea Giudiceandrea via QGIS-Developer wrote:
>> *Raymond Nijssen*
>> /Wed Dec 7 07:39:50 PST 2022/
>> ------------------------------------------------------------------------
>> I'm trying to change the dataSourceUri of an existing layer
> 
> Hi Raymond,
> AFAIK you need to use setDataSource [1] directly on the layer an not 
> setDataSourceUri on the data provider.
> 
> E.g.:
> 
> layer.setDataSource(new_ds, layer_name, 'ogr')
> 
> 
> Best regards.
> 
> Andrea
> 
> [1] 
> https://qgis.org/pyqgis/master/core/QgsMapLayer.html#qgis.core.QgsMapLayer.setDataSource
> 
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the QGIS-Developer mailing list