[Qgis-user] Invalid data source loading vector layer using PyQGIS
Hi list, I'm trying to load a vector layer (shapefile) using PyQGIS and especially QgsVectorLayer constructor. I had a look at the following link to start with : http://www.qgis.org/pyqgis-cookbook/intro.html#python-applications and also : http://www.qgis.org/pyqgis-cookbook/loadlayer.html#vector-layers So my script looks like : *QgsApplication.setPrefixPath(/usr,True)* *QgsApplication.initQgis()* *myLayer = QgsVectorLayer(/tmp/data.gboundaries.shp,gboundaries,ogr)* But I get this error message : Data source is invalid and my layer is invalid. However, it is working when I launch it in the QGIS python console. Do I need to set/export any variable outside of QGIS to use the ogr provider? Does anybody has any clue about my problem? FYI, I'm working on Ubuntu 10.10, with Python 2.6 and QGIS 1.6 (from the packages). Thanks for your help, Cheers, Mathieu ___ Qgis-user mailing list Qgis-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-user
[Qgis-user] plugin Statistic dont work
Hello: i need working whith Statistic for vector layer and the plugin crash every time. I dont know what is the problem. If someone could help me I pasted the error messege here below THANKs Betina Ha ocurrido un error mientras se ejecutaba el código de Python: Traceback (most recent call last): File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4.py, line 168, in resizeEvent self.draw() File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4agg.py, line 130, in draw FigureCanvasAgg.draw(self) File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py, line 313, in draw self.renderer = self.get_renderer() File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py, line 319, in get_renderer try: self._lastKey, self.renderer TypeError: 'sip.methoddescriptor' object is not callable Versión de Python: 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] Versión de QGIS: 1.6.0-Copiapo Copiapo, exported Ruta de Python: ['C:\\Documents and Settings\\tinpy\\.qgis\\python\\plugins\\GeoCoding', 'C:/OSGeo4W/apps/qgis/./python', 'C:/Documents and Settings/tinpy/.qgis/python', 'C:/Documents and Settings/tinpy/.qgis/python/plugins', 'C:/OSGeo4W/apps/qgis/./python/plugins', 'C:\\Archivos de programa\\ArcGIS\\bin', 'C:\\WINDOWS\\system32\\python25.zip', 'C:\\OSGeo4W\\apps\\Python25\\DLLs', 'C:\\OSGeo4W\\apps\\Python25\\lib', 'C:\\OSGeo4W\\apps\\Python25\\lib\\plat-win', 'C:\\OSGeo4W\\apps\\Python25\\lib\\lib-tk', 'C:\\OSGeo4W\\apps\\qgis\\bin', 'C:\\OSGeo4W\\apps\\Python25', 'C:\\OSGeo4W\\apps\\Python25\\lib\\site-packages', 'C:\\OSGeo4W\\apps\\Python25\\lib\\site-packages\\win32', 'C:\\OSGeo4W\\apps\\Python25\\lib\\site-packages\\win32\\lib', 'C:\\OSGeo4W\\apps\\Python25\\lib\\site-packages\\Pythonwin', 'C:\\OSGeo4W\\apps\\Python25\\lib\\site-packages\\wx-2.8-msw-unicode', '~/.qgis/python', 'C:\\Documents and Settings\\tinpy\\.qgis\\python\\plugins\\fTools\\tools', 'C:\\Documents and Settings\\tinpy\\.qgis\\python\\plugins\\mmqgis/forms', 'D:/CumPARTIDOS/NO BORRAR/IPAP-2011/SIG-N2-2011/M04/A01 - Promotores de salud'] ---___ Qgis-user mailing list Qgis-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-user
Re: [Qgis-user] plugin Statistic dont work
I can confirm the same error using qgis-dev package from OSGeoW. I'm on Windows XP x64. Python version: 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] QGIS version: 1.7.0-Wroclaw Wroclaw, 15786M - John On Fri, Apr 22, 2011 at 12:23 PM, Betina Zucchino bzucch...@yahoo.com.arwrote: Hello: i need working whith Statistic for vector layer and the plugin crash every time. I dont know what is the problem. If someone could help me I pasted the error messege here below THANKs Betina Ha ocurrido un error mientras se ejecutaba el código de Python: Traceback (most recent call last): File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4.py, line 168, in resizeEvent self.draw() File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4agg.py, line 130, in draw FigureCanvasAgg.draw(self) File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py, line 313, in draw self.renderer = self.get_renderer() File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py, line 319, in get_renderer try: self._lastKey, self.renderer TypeError: 'sip.methoddescriptor' object is not callable Versión de Python: 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] Versión de QGIS: 1.6.0-Copiapo Copiapo, exported Ruta de Python: ['C:\\Documents and Settings\\tinpy\\.qgis\\python\\plugins\\GeoCoding', 'C:/OSGeo4W/apps/qgis/./python', 'C:/Documents and Settings/tinpy/.qgis/python', 'C:/Documents and Settings/tinpy/.qgis/python/plugins', 'C:/OSGeo4W/apps/qgis/./python/plugins', 'C:\\Archivos de programa\\ArcGIS\\bin', 'C:\\WINDOWS\\system32\\python25.zip', 'C:\\OSGeo4W\\apps\\Python25\\DLLs', 'C:\\OSGeo4W\\apps\\Python25\\lib', 'C:\\OSGeo4W\\apps\\Python25\\lib\\plat-win', 'C:\\OSGeo4W\\apps\\Python25\\lib\\lib-tk', 'C:\\OSGeo4W\\apps\\qgis\\bin', 'C:\\OSGeo4W\\apps\\Python25', 'C:\\OSGeo4W\\apps\\Python25\\lib\\site-packages', 'C:\\OSGeo4W\\apps\\Python25\\lib\\site-packages\\win32', 'C:\\OSGeo4W\\apps\\Python25\\lib\\site-packages\\win32\\lib', 'C:\\OSGeo4W\\apps\\Python25\\lib\\site-packages\\Pythonwin', 'C:\\OSGeo4W\\apps\\Python25\\lib\\site-packages\\wx-2.8-msw-unicode', '~/.qgis/python', 'C:\\Documents and Settings\\tinpy\\.qgis\\python\\plugins\\fTools\\tools', 'C:\\Documents and Settings\\tinpy\\.qgis\\python\\plugins\\mmqgis/forms', 'D:/CumPARTIDOS/NO BORRAR/IPAP-2011/SIG-N2-2011/M04/A01 - Promotores de salud'] --- ___ Qgis-user mailing list Qgis-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-user ___ Qgis-user mailing list Qgis-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-user
Re: [Qgis-user] plugin Statistic dont work
2011/4/22 Betina Zucchino bzucch...@yahoo.com.ar Traceback (most recent call last): File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4.py, line 168, in resizeEvent self.draw() File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4agg.py, line 130, in draw FigureCanvasAgg.draw(self) File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py, line 313, in draw self.renderer = self.get_renderer() File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py, line 319, in get_renderer try: self._lastKey, self.renderer TypeError: 'sip.methoddescriptor' object is not callable There is an incompatibility between python and sip versions in osgeo4w affecting the qt4agg backend in matplotlib. I filed a bug about this some time ago[1]. I had to patch matplotlib in order to get the qt4agg backend working in osgeo4w, see the bug report for details. Goyo [1] http://trac.osgeo.org/osgeo4w/ticket/213 ___ Qgis-user mailing list Qgis-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-user
Re: [Qgis-user] QGIS Webclient checked in
Thanks Andreas for this magnificent software, is interesting to see the QGIS's projects in the Web. Regards, Samuel Mesa. P.S:I attached a small contribution from the proposed translation file into Spanish. 2011/4/20 Andreas Neumann a.neum...@carto.net: Hi all, I initially checked in QGIS webclient. You can find the source at http://svn.osgeo.org/qgis/trunk/qgiswebclient/ I have to apologize upfront that I am at holidays until May 3. Until then I cannot answer questions regarding the web client. Pirmin Kalberer knows a bit about the client. If someone wants to translate, you can find the translation file at http://svn.osgeo.org/qgis/trunk/qgiswebclient/js/Translations.js There is a readme file containing some information about installation: http://svn.osgeo.org/qgis/trunk/qgiswebclient/readme.txt Andreas -- -- Andreas Neumann Böschacherstrasse 10A 8624 Grüt (Gossau ZH) Switzerland ___ Qgis-user mailing list Qgis-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-user -- --- |\__ (: __)( |/ Soluciones Geoinformáticas Libres http://geotux.tuxfamily.org/ Linux registered user #373582, http://counter.li.org/ Translations.js Description: JavaScript source ___ Qgis-user mailing list Qgis-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-user
Re: [Qgis-user] plugin Statistic dont work
Hola Bettina, the bug is now closed as fixed (thanks, Jürgen) so updating osgeo4w should be enough. If you used the standalone installer I don't know if you can update. If you don't then do this: 1. Open C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py in notepad or any text editor. The exact path can vary if you installed in a custom directory. 2. Look for this code (it should be lines 319, 320 and 321): try: self._lastKey, self.renderer except AttributeError: need_new_renderer = True else: need_new_renderer = (self._lastKey != key) 3. Change the second line (320) to this: except (AttributeError, TypeError): need_new_renderer = True 4. Save changes and try again. You can make a backup of the file before making any changes, just for safety. But now that the bug is fixed updating osgeo4w is the right way to go. Goyo 2011/4/22 Betina Zucchino bzucch...@yahoo.com.ar Hola Goyo: Hablas en español? Te agradezco lo que me respondiste. Pero no manejo Python y no se que es lo que tendría que hacer con eso que figura en la página... Te pido disculpas, soy usuaria de qgis, pero sin idea de programación. Lo que alcancé a hacer es abrir una ventana de python 2.7 y pegar todas las sentencias que figuran en la pagina sin saber cómo continuar. Hice Debug... En fin, muchas gracias igualmente. Betina --- El vie 22-abr-11, Goyo goyod...@gmail.com escribió: De: Goyo goyod...@gmail.com Asunto: Re: [Qgis-user] plugin Statistic dont work Para: Betina Zucchino bzucch...@yahoo.com.ar Cc: qgis-user@lists.osgeo.org Fecha: viernes, 22 de abril de 2011, 17:00 2011/4/22 Betina Zucchino bzucch...@yahoo.com.ar Traceback (most recent call last): File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4.py, line 168, in resizeEvent self.draw() File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4agg.py, line 130, in draw FigureCanvasAgg.draw(self) File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py, line 313, in draw self.renderer = self.get_renderer() File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py, line 319, in get_renderer try: self._lastKey, self.renderer TypeError: 'sip.methoddescriptor' object is not callable There is an incompatibility between python and sip versions in osgeo4w affecting the qt4agg backend in matplotlib. I filed a bug about this some time ago[1]. I had to patch matplotlib in order to get the qt4agg backend working in osgeo4w, see the bug report for details. Goyo [1] http://trac.osgeo.org/osgeo4w/ticket/213 ___ Qgis-user mailing list Qgis-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-user
Re: [Qgis-user] plugin Statistic dont work
Hello Goyo, Thanks so much! It worked! I did what you wrote, because updating osgeo4w didnt work. I´ve tried more than once and there were an error whith Python. Betina --- El vie 22-abr-11, Goyo goyod...@gmail.com escribió: De: Goyo goyod...@gmail.com Asunto: Re: [Qgis-user] plugin Statistic dont work Para: Betina Zucchino bzucch...@yahoo.com.ar Cc: qgis-user qgis-user@lists.osgeo.org Fecha: viernes, 22 de abril de 2011, 18:57 Hola Bettina, the bug is now closed as fixed (thanks, Jürgen) so updating osgeo4w should be enough. If you used the standalone installer I don't know if you can update. If you don't then do this: 1. Open C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py in notepad or any text editor. The exact path can vary if you installed in a custom directory. 2. Look for this code (it should be lines 319, 320 and 321): try: self._lastKey, self.renderer except AttributeError: need_new_renderer = True else: need_new_renderer = (self._lastKey != key) 3. Change the second line (320) to this: except (AttributeError, TypeError): need_new_renderer = True 4. Save changes and try again. You can make a backup of the file before making any changes, just for safety. But now that the bug is fixed updating osgeo4w is the right way to go. Goyo 2011/4/22 Betina Zucchino bzucch...@yahoo.com.ar Hola Goyo: Hablas en español? Te agradezco lo que me respondiste. Pero no manejo Python y no se que es lo que tendría que hacer con eso que figura en la página... Te pido disculpas, soy usuaria de qgis, pero sin idea de programación. Lo que alcancé a hacer es abrir una ventana de python 2.7 y pegar todas las sentencias que figuran en la pagina sin saber cómo continuar. Hice Debug... En fin, muchas gracias igualmente. Betina --- El vie 22-abr-11, Goyo goyod...@gmail.com escribió: De: Goyo goyod...@gmail.com Asunto: Re: [Qgis-user] plugin Statistic dont work Para: Betina Zucchino bzucch...@yahoo.com.ar Cc: qgis-user@lists.osgeo.org Fecha: viernes, 22 de abril de 2011, 17:00 2011/4/22 Betina Zucchino bzucch...@yahoo.com.ar Traceback (most recent call last): File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4.py, line 168, in resizeEvent self.draw() File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4agg.py, line 130, in draw FigureCanvasAgg.draw(self) File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py, line 313, in draw self.renderer = self.get_renderer() File C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py, line 319, in get_renderer try: self._lastKey, self.renderer TypeError: 'sip.methoddescriptor' object is not callable There is an incompatibility between python and sip versions in osgeo4w affecting the qt4agg backend in matplotlib. I filed a bug about this some time ago[1]. I had to patch matplotlib in order to get the qt4agg backend working in osgeo4w, see the bug report for details. Goyo [1] http://trac.osgeo.org/osgeo4w/ticket/213 ___ Qgis-user mailing list Qgis-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-user
Re: [Qgis-user] Invalid data source loading vector layer using PyQGIS
Hi Mathieu Have a look at this QGIS plugin - Load Them All, a QGIS plugin http://geotux.tuxfamily.org/index.php?option=com_contenttask=viewlang=enid=264 Download and install, then see how the shapefile is retrieved in this plugin. Noli On 4/23/11, Mathieu Coudert mathieu.coud...@gmail.com wrote: Hi list, I'm trying to load a vector layer (shapefile) using PyQGIS and especially QgsVectorLayer constructor. I had a look at the following link to start with : http://www.qgis.org/pyqgis-cookbook/intro.html#python-applications and also : http://www.qgis.org/pyqgis-cookbook/loadlayer.html#vector-layers So my script looks like : *QgsApplication.setPrefixPath(/usr,True)* *QgsApplication.initQgis()* *myLayer = QgsVectorLayer(/tmp/data.gboundaries.shp,gboundaries,ogr)* But I get this error message : Data source is invalid and my layer is invalid. However, it is working when I launch it in the QGIS python console. Do I need to set/export any variable outside of QGIS to use the ogr provider? Does anybody has any clue about my problem? FYI, I'm working on Ubuntu 10.10, with Python 2.6 and QGIS 1.6 (from the packages). Thanks for your help, Cheers, Mathieu ___ Qgis-user mailing list Qgis-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-user