DOC: Clarify that file databases can also be written using to_file (#2821)

This commit is contained in:
Pieter Roggemans
2023-03-09 11:47:28 +01:00
committed by GitHub
parent 1a444c1905
commit a0d4cf6208
2 changed files with 16 additions and 1 deletions
+12
View File
@@ -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
+4 -1
View File
@@ -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
"""