diff --git a/geopandas/geodataframe.py b/geopandas/geodataframe.py index 2e54388..d5be395 100644 --- a/geopandas/geodataframe.py +++ b/geopandas/geodataframe.py @@ -1203,6 +1203,14 @@ individually so that features may have different properties With selected drivers you can also append to a file with `mode="a"`: >>> gdf.to_file('dataframe.shp', mode="a") # doctest: +SKIP + + Using the engine-specific keyword arguments it is possible to e.g. create a + spatialite file with a custom layer name: + + >>> gdf.to_file( + ... 'dataframe.sqlite', driver='SQLite', spatialite=True, layer='test' + ... ) # doctest: +SKIP + """ from geopandas.io.file import _to_file @@ -1902,6 +1910,10 @@ individually so that features may have different properties This method requires SQLAlchemy and GeoAlchemy2, and a PostgreSQL Python driver (e.g. psycopg2) to be installed. + It is also possible to use :meth:`~GeoDataFrame.to_file` to write to a database. + Especially for file geodatabases like GeoPackage or SpatiaLite this can be + easier. + Parameters ---------- name : str diff --git a/geopandas/io/sql.py b/geopandas/io/sql.py index 40f8daa..bbbc622 100644 --- a/geopandas/io/sql.py +++ b/geopandas/io/sql.py @@ -112,6 +112,9 @@ def _read_postgis( Returns a GeoDataFrame corresponding to the result of the query string, which must contain a geometry column in WKB representation. + It is also possible to use :meth:`~GeoDataFrame.read_file` to read from a database. + Especially for file geodatabases like GeoPackage or SpatiaLite this can be easier. + Parameters ---------- sql : string @@ -149,7 +152,7 @@ def _read_postgis( SpatiaLite - >>> sql = "SELECT ST_Binary(geom) AS geom, highway FROM roads" + >>> sql = "SELECT ST_AsBinary(geom) AS geom, highway FROM roads" >>> df = geopandas.read_postgis(sql, con) # doctest: +SKIP """