O'Reilly logo

PostGIS Cookbook by Bborie Park, Stephen Vincent Mather, Thomas J. Kraft, Paolo Corti

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

  1. 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
    
  2. Install PL/Python on the database (you could ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required