Tag Archives: QGIS

QGIS Processing crash

I’ve been looking at setting up some graphical models in QGIS recently using the tools available through the Processing option. I ran into some issues on my installation of QGIS 2.2 / Processing 2.0 on Ubuntu 12.04.4 64bit that I wasn’t able to recreate using the OSGeo4W install on Windows 7 Home Premium 64bit.

The problem was that I could build the models fine, but when I added in an output file for the model, the application crashed. Doing a bit of hunting around, this seems to be a known issue (see http://hub.qgis.org/issues/8716). It looks like a related bug report has been moved to a priority of ‘Blocker’ (http://hub.qgis.org/issues/6785).

So the way round the crash is to save your model with no name entered in the output field, then right click on the algorithm box and select edit (rather than double clicking to open that dialog). Add in the name of your output and save the model again. It should then all work as built.

Tagged ,

otb on Mint 14

OK – I had otb set up to run through the SEXTANTE plugin in qgis usingthe standard repository as mentioned in the online help:

sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable

Then there was an upgrade of the otb libraries and everything stopped working – not good. I don’t know if what I have done as a work around is a sensible thing to do but it seems to have gotten my installation up and running again:

  • Uninstall the SEXTANTE plugin
  • Uninstall qgis and anything else installed using the ubuntugis-unstable repository
  • Install the stable repository – sudo apt-add-repository ppa:ubuntugis/ubuntugis
  • Run sudo apt-get update
  • Then use sudo apt-get install libotb otb-bin otb-bin-qt python-otb to install the libraries and applications
  • Reinstall the SEXTANTE plugin and hopefully it will all work

That worked for me but I don’t know what will happen when qgis 2.x is released.

Tagged ,

QGIS Python Console

Some quick pointers for using the Python console in QGIS.

1) create reference to a shapefile and open it using OGR

layer = QgsVectorLayer("path\\to\\file.shp", "layer_name_you_like", "ogr")
if not layer.isValid():
 print "FAIL"

2) Render the layer


3) Interrogate the layer

layer = qgis.utils.iface.activeLayer()
Tagged , ,

Understanding a QGIS Plugin

Right, this might be a bit long but hopefully it will help explain how to put together a QGIS plugin.

First I would install the “Plugin Builder” plugin and create a base using that. The path of the plugin you are creating should be something similar to .qgis\python\plugins\ and should contain the following files:

  • <pluginname>.py
  • ui_<pluginname>.py
  • resources.py
  • __init__.py

The __init__.py file will include the set-up details similar to the following (for the purposes of this post, the plugin is called Raster Killer – it just resizes rasters at the moment using PIL): Continue reading

Tagged , , , , , ,

Register QGIS Python Console

Disclaimer: You do the following at your own risk.

To use Python Image Library with QGIS you need to install PIL into the QGIS python install location. Open up your version of QGIS and make sure the Python Interpreter is available (Plugins | Python Console). Then type in the code below. This will register the version of Python used by QGIS in the Windows registry. Other versions e.g. 2.6 for pythonxy will be registered elsewhere so there shouldn’t be a conflict but I wouldn’t count on it. Then fire up regedit and browse to HKEY_LOCAL_MACHINE | SOFTWARE | Python | Pythoncore and change the name of the Key entry from whatever very long name it is to 2.x where x is the version of Python 2 being used: so for QGIS 1.7 it should be changed to 2.5.

Then go to http://effbot.org/downloads/#pil and get the correct binary of PIL for your QGIS install. It is an exe so it should pick up the registered version and install to the correct location. Then you should be able to use PIL from QGIS. Continue reading

Tagged ,