postgresql - Using PostGIS on Python 3 -
i'm using python 3 , need connect postgre postgis extensions. i'm intending utilize psycopg2 driver. ppygis extension found, works on python 2.7 not 3.3.0. 1 knows solution working on 3.3.0 ?
if not doing fancy geometry objects on client side (python), psycopg2 can basic info using native info types geometry accessors, or other gis output formats geojson. allow server (postgresql/postgis) hard work.
here random illustration homecoming geojson shapes within 1 km of point of interest:
import psycopg2 conn = psycopg2.connect(database='postgis', user='postgres') curs = conn.cursor() # find distance within 1 km of point-of-interest poi = (-124.3, 53.2) # longitude, latitude # table 'my_points' has geography column 'geog' curs.execute("""\ select gid, st_asgeojson(geog), st_distance(geog, poi) my_points, (select st_makepoint(%s, %s)::geography poi) f st_dwithin(geog, poi, 1000);""", poi) row in curs.fetchall(): print(row)
python postgresql postgis
No comments:
Post a Comment