geopandas.read_postgis

geopandas.read_postgis(sql, con, geom_col='geom', crs=None, index_col=None, coerce_float=True, parse_dates=None, params=None, chunksize=None)

Returns a GeoDataFrame corresponding to the result of the query string, which must contain a geometry column in WKB representation.

Parameters
sqlstring

SQL query to execute in selecting entries from database, or name of the table to read from the database.

conDB connection object or SQLAlchemy engine

Active connection to the database to query.

geom_colstring, default ‘geom’

column name to convert to shapely geometries

crsdict or str, optional

CRS to use for the returned GeoDataFrame; if not set, tries to determine CRS from the SRID associated with the first geometry in the database, and assigns that to all geometries.

chunksizeint, default None

If specified, return an iterator where chunksize is the number of rows to include in each chunk.

See the documentation for pandas.read_sql for further explanation
of the following parameters:
index_col, coerce_float, parse_dates, params, chunksize
Returns
GeoDataFrame

Examples

PostGIS >>> sql = “SELECT geom, kind FROM polygons” SpatiaLite >>> sql = “SELECT ST_AsBinary(geom) AS geom, kind FROM polygons” >>> df = geopandas.read_postgis(sql, con)