Writing PostGIS functions with PL/Python
In this recipe, you will write a Python function for PostGIS using the PL/Python language. The PL/Python procedural language allows you to write PostgreSQL functions with the Python language.
You will use Python for querying the openweathermap.org web services, already used in a previous recipe, to get the weather for a PostGIS geometry from within a PostgreSQL function.
Getting ready
Verify whether your PostgreSQL server installation has PL/Python support. On Windows, this should be already included, but this is not the default if you are using, for example, Ubuntu 12.4 LTS, so you will most likely need to install it:
$ sudo apt-get install postgresql-plpython-9.1
Install PL/Python on the database (you could consider installing it in your
template1
database; in this way, every newly created database will have PL/Python support by default):Note
You could alternatively add PL/Python support to your database using the
createlang
shell command (this is the...