Hi list,<div><br></div><div>I'm trying to load a vector layer (shapefile) using PyQGIS and especially QgsVectorLayer constructor.</div><div>I had a look at the following link to start with : </div><div><a href="http://www.qgis.org/pyqgis-cookbook/intro.html#python-applications">http://www.qgis.org/pyqgis-cookbook/intro.html#python-applications</a></div>
<div>and also : </div><div><a href="http://www.qgis.org/pyqgis-cookbook/loadlayer.html#vector-layers">http://www.qgis.org/pyqgis-cookbook/loadlayer.html#vector-layers</a></div><div><br></div><div>So my script looks like : </div>
<div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; "><br></span></div><div><i><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; ">QgsApplication.</span><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; "></span><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; ">setPrefixPath("</span><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; "></span><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; ">/usr",True)</span></i></div>
<div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; "><i>QgsApplication.initQgis()</i></span></div><div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; "><i>myLayer = QgsVectorLayer("/tmp/data.gboundaries.shp","gboundaries","ogr")</i></span></div>
<div><br></div><div>But I get this error message : "<span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; ">Data source is invalid" and my layer is invalid.</span></div>
<div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; "><br></span></div><div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; ">However, it is working when I launch it in the QGIS python console.</span></div>
<div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; "><br></span></div><div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; ">Do I need to set/export any variable outside of QGIS to use the ogr provider?</span></div>
<div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; ">Does anybody has any clue about my problem?</span></div><div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; "><br>
</span></div><div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; ">FYI, </span><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; ">I'm working on Ubuntu 10.10, with Python 2.6 and QGIS 1.6 (from the packages).</span></div>
<div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; "><br></span></div><div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; ">Thanks for your help,</span></div>
<div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; "><br></span></div><div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; ">Cheers,</span></div>
<div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; "><br></span></div><div><span class="Apple-style-span" style="font-family: 'Droid Sans', arial, sans-serif; font-size: 13px; ">Mathieu</span></div>