Hello, <br><br>I am a newbie about qgis I am trying to load a vector layer from a shape file. I can load it from add layer button but can not load from the plugin I am tryin to write. My code is below:<br><br><br> def unload(self):<br>
# Remove the plugin menu item and icon<br> self.iface.removePluginMenu("&Read shp for calculations",self.action)<br> self.iface.removeToolBarIcon(self.action)<br> # run method that performs all the real work<br>
def run(self): <br> <br> fileName = QFileDialog.getOpenFileName(None,QString.fromLocal8Bit("Select a file:"),"", "*.shp *.gml")<br> if fileName.isNull():<br><br> QMessageBox.information(None, "Cancel", "File selection canceled")<br>
<br> else:<br><br> <br> vlayer = QgsVectorLayer( fileName, "hebe", "ogr")<br> provider = vlayer.dataProvider()<br> feat = QgsFeature()<br> allAttrs = provider.attributeIndexes()<br>
provider.select(allAttrs)<br><br> while provider.nextFeature(feat):<br> geom = feat.geometry()<br> print "Feature ID %d: " % <a href="http://feat.id">feat.id</a>() <br><br>This piece of code returns nothing to me. What is wrong here.<br>
<br>Thanks for help<br><br>