Skip to content

4.4 Use H2GIS with Python

Bocher edited this page Mar 9, 2018 · 15 revisions

Introduction

The following example demonstrates how to use H2GIS with the Python scripting language. The advantage is the ability to run it on dedicated server without X11.

Requirements:

  • To use H2GIS, you have to install Java from version 7.

Install H2GIS

To install H2GIS, follow this steps:

  • Download the latest H2GIS web interface on the home page, unzip it.
  • On Linux you can execute the following commands:
~ $ wget https://github.com/orbisgis/h2gis/releases/download/v1.3.2/h2gis-dist-1.3.2-bin.zip -O h2gis.zip
~ $ unzip h2gis.zip

Install psycopg2

http://initd.org/psycopg/docs/install.html#installation

Run H2GIS as a PosgreSQL sever mode

On Windows

java -cp "" org.h2.tools.Server -pg

On Linux

java -cp  org.h2.tools.Server -pg

Initialize the H2GIS extension

Execute the following SQL syntax:

CREATE ALIAS IF NOT EXISTS H2GIS_SPATIAL FOR "org.h2gis.functions.factory.H2GISFunctions.load";
CALL H2GIS_SPATIAL();

Execute H2GIS instructions thanks to Python commands

Clone this wiki locally