Skip to main content
minor edittings
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

OGR says that my data source is invalid when iI use the method QgsVectorLayer in PyQgisPyQGIS

I am begining with PyQgisPyQGIS and QgisQGIS in general. I wanted a way to create a layer via python, so i downloaded "Plugin Builder" and starded coding. Here's the code :

def activatePlugin (self):
    global limitAer,limitSou ,limitOra , limitENE, limitCha, layer, QgsVectorLayer

    layer = QgsVectorLayer('/Users/fse/Desktop/54_028_380_EXE_CCE_SID_CIR_001_B2/SHAPE/couche_test.shp', 'couche_test', 'ogr')
    
    QgsMapLayerRegistry.instance().addMapLayer(layer)
    
    if not layer.isValid():
        print "Layer was not loaded!"
    else:
        print "Layer was loaded successfully!"

I get a "Layer was not loaded" response and a print in the OGR console telling me that the source data is invalid.

I have tried all sorts of slashes, backslashes etc... It is basically always the same.

OGR says that my data source is invalid when i use the method QgsVectorLayer in PyQgis

I am begining with PyQgis and Qgis in general. I wanted a way to create a layer via python, so i downloaded "Plugin Builder" and starded coding. Here's the code :

def activatePlugin (self):
    global limitAer,limitSou ,limitOra , limitENE, limitCha, layer, QgsVectorLayer

    layer = QgsVectorLayer('/Users/fse/Desktop/54_028_380_EXE_CCE_SID_CIR_001_B2/SHAPE/couche_test.shp', 'couche_test', 'ogr')
    
    QgsMapLayerRegistry.instance().addMapLayer(layer)
    
    if not layer.isValid():
        print "Layer was not loaded!"
    else:
        print "Layer was loaded successfully!"

I get a "Layer was not loaded" response and a print in the OGR console telling me that the source data is invalid.

I have tried all sorts of slashes, backslashes etc... It is basically always the same.

OGR says that my data source is invalid when I use the method QgsVectorLayer in PyQGIS

I am begining with PyQGIS and QGIS in general. I wanted a way to create a layer via python, so i downloaded "Plugin Builder" and starded coding. Here's the code :

def activatePlugin (self):
    global limitAer,limitSou ,limitOra , limitENE, limitCha, layer, QgsVectorLayer

    layer = QgsVectorLayer('/Users/fse/Desktop/54_028_380_EXE_CCE_SID_CIR_001_B2/SHAPE/couche_test.shp', 'couche_test', 'ogr')
    
    QgsMapLayerRegistry.instance().addMapLayer(layer)
    
    if not layer.isValid():
        print "Layer was not loaded!"
    else:
        print "Layer was loaded successfully!"

I get a "Layer was not loaded" response and a print in the OGR console telling me that the source data is invalid.

I have tried all sorts of slashes, backslashes etc... It is basically always the same.

I am begining with PyQgis and Qgis in general. I wanted a way to create a layer via python, so i downloaded "Plugin Builder" and starded coding. Here's the code :

def activatePlugin (self):
    global limitAer,limitSou ,limitOra , limitENE, limitCha, layer, QgsVectorLayer

    layer = QgsVectorLayer('/Users/fse/Desktop/54_028_380_EXE_CCE_SID_CIR_001_B2/SHAPE/couche_test.shp', 'couche_test', 'ogr')
    
    QgsMapLayerRegistry.instance().addMapLayer(layer)
    
    if not layer.isValid():
        print "Layer was not loaded!"
    else:
        print "Layer was loaded successfully!"

I get a "Layer was not loaded" response and a print in the OGR console telling me that the source data is invalid.

ps : iI have tried all sorts of slashes, backslashes etc... It is basically always the same.

I am begining with PyQgis and Qgis in general. I wanted a way to create a layer via python, so i downloaded "Plugin Builder" and starded coding. Here's the code :

def activatePlugin (self):
    global limitAer,limitSou ,limitOra , limitENE, limitCha, layer, QgsVectorLayer

    layer = QgsVectorLayer('/Users/fse/Desktop/54_028_380_EXE_CCE_SID_CIR_001_B2/SHAPE/couche_test.shp', 'couche_test', 'ogr')
    
    QgsMapLayerRegistry.instance().addMapLayer(layer)
    
    if not layer.isValid():
        print "Layer was not loaded!"
    else:
        print "Layer was loaded successfully!"

I get a "Layer was not loaded" response and a print in the OGR console telling me that the source data is invalid.

ps : i tried all sorts of slashes, backslashes etc... It is basically always the same.

I am begining with PyQgis and Qgis in general. I wanted a way to create a layer via python, so i downloaded "Plugin Builder" and starded coding. Here's the code :

def activatePlugin (self):
    global limitAer,limitSou ,limitOra , limitENE, limitCha, layer, QgsVectorLayer

    layer = QgsVectorLayer('/Users/fse/Desktop/54_028_380_EXE_CCE_SID_CIR_001_B2/SHAPE/couche_test.shp', 'couche_test', 'ogr')
    
    QgsMapLayerRegistry.instance().addMapLayer(layer)
    
    if not layer.isValid():
        print "Layer was not loaded!"
    else:
        print "Layer was loaded successfully!"

I get a "Layer was not loaded" response and a print in the OGR console telling me that the source data is invalid.

I have tried all sorts of slashes, backslashes etc... It is basically always the same.

Source Link

OGR says that my data source is invalid when i use the method QgsVectorLayer in PyQgis

I am begining with PyQgis and Qgis in general. I wanted a way to create a layer via python, so i downloaded "Plugin Builder" and starded coding. Here's the code :

def activatePlugin (self):
    global limitAer,limitSou ,limitOra , limitENE, limitCha, layer, QgsVectorLayer

    layer = QgsVectorLayer('/Users/fse/Desktop/54_028_380_EXE_CCE_SID_CIR_001_B2/SHAPE/couche_test.shp', 'couche_test', 'ogr')
    
    QgsMapLayerRegistry.instance().addMapLayer(layer)
    
    if not layer.isValid():
        print "Layer was not loaded!"
    else:
        print "Layer was loaded successfully!"

I get a "Layer was not loaded" response and a print in the OGR console telling me that the source data is invalid.

ps : i tried all sorts of slashes, backslashes etc... It is basically always the same.