I'm trying to setup a basic working postgis setup with python ppygis package.
>>> import psycopg2 >>> import ppygis >>> connection = psycopg2.connect(database='spre', user='postgres') >>> cursor = connection.cursor() >>> cursor.execute('CREATE TABLE test (geometry GEOMETRY)') >>> cursor.execute('INSERT INTO test VALUES(%s)', (ppygis.Point(1.0, 2.0),)) >>> cursor.execute('SELECT * from test') >>> point = cursor.fetchone() >>> print point 0101000000000000000000F03F0000000000000040 >>>
I should have got a python object with separate X and Y coordinate. Something like
>>> Point(X: 1.0, Y: 2.0)
What am I doing wrong? I'm following http://www.fabianowski.eu/projects/ppygis/usage.html#installation
For posterity. I couldn't make it work, so to get point data this was what I did,
>>> cursor.execute('SELECT ST_AsGeoJSON(geometry) FROM test') >>> point = cursor.fetchone() >>> print json.loads(point)['coordinates'] [1,2]