python - Geopandas PostGIS connection -
i started using geopandas in python of spatial work , pleased - i'm trying read in postgis features , don't quite understand how parameterize database connection, , didn't seem clear in documentation:
geodataframe.from_postgis(sql, con, geom_col='geom', crs=none, index_col=none, coerce_float=true, params=none)
this simple question, wanted know needs go in 'con' - assume string database connection information? in format? setting 'sql' seems straightforward. appreciated - thanks!
example:
import geopandas gpd import psycopg2 /*(if postgres/postgis) con = psycopg2.connect(database="your database", user="user",password="password",host="your host") sql= "select geom, x,y,z your_table" df=gpd.geodataframe.from_postgis(sql,con,geom_col='geom' )
Comments
Post a Comment