[Qgis-developer] Python ogr driver issue (was ----> (no subject))

Tim Sutton lists at linfiniti.com
Fri Aug 24 10:08:52 PDT 2012


Hi (adding a proper subject line to your messages is always nice)

On Fri, Aug 24, 2012 at 12:09 PM, ludo <ludovic.granjon at wanadoo.fr> wrote:
> Hi all
>
> I try to start the developpement for a custom application with qgis, so I
> try simple things like add a vector layer but I have some problems. In a
> python console when I try to do something like that :
>
>>>> core.QgsApplication.setPrefixPath('/usr',True)
>>>> core.QgsApplication.initQgis()
>>>> l = core.QgsVectorLayer('/home/ludo/data/test.shp', 'test', 'ogr')
>>>> l.isValid()
>
> I always have a False result
>
> But if I try in the python console of qgis :
>
>>>> l = QgsVectorLayer('/home/ludo/data/test.shp', 'test', 'ogr')
>>>> l.isValid()
>
> The result is True
>
> Is someone have an idea ? Are there any other documentation that
> http://qgis.org/pyqgis-cookbook/


There is a growing set of python unit tests that you can consult for ideas.

Providiing the stdout from your console might help us to understand
where your problem originates. Here is a little sript I often use:

-----------------------------------------------------------------

import os
import sys
from qgis.core import QgsApplication, QgsProviderRegistry

myUseDefaultPathFlag = True
QGISAPP.setPrefixPath('/usr', myUseDefaultPathFlag)
QGISAPP.initQgis()
s = QGISAPP.showSettings()
print s
r = QgsProviderRegistry.instance()
if not 'ogr' in r.providerList():
    print 'Could not find OGR provider!'
else:
    print 'Providers found ok!'

-----------------------------------------------------------------

Hope that helps!


Tim
>
> Thanks a lot
>
> Ludovic
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>



-- 
Tim Sutton - QGIS Project Steering Committee Member (Release  Manager)
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Visit http://linfiniti.com to find out about:
 * QGIS programming and support services
 * Mapserver and PostGIS based hosting plans
 * FOSS Consulting Services
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
==============================================


More information about the Qgis-developer mailing list