geost.io.Geopackage#
- class geost.io.Geopackage(file: str | Path)[source]#
Read and inspect the contents of a geopackage file. The class is designed to be used as a context manager to ensure the connection to the geopackage is closed after use.
- Parameters:
file (str | Path) – Valid string path to the Geopackage file.
Examples
Check the available layers in a geopackage file:
>>> print(Geopackage("my_geopackage.gpkg").layers())
Read the first five records of a table in the geopackage for a quick inspection:
>>> with Geopackage("my_geopackage.gpkg") as gp: ... print(gp.table_head("my_table"))
For use without a context manager:
>>> gp = Geopackage("my_geopackage.gpkg") >>> gp.get_connection() >>> table = gp.read_table("my_table") # Returns a DataFrame of the table.
Methods
__init__
(file)close
()Close the connection to the geopackage file.
get_column_names
(table)Get the column names of a table in the geopackage.
Create a manual sqlite3 connection to the geopackage file.
layers
()Return a Pandas DataFrame containing the layers and associated geometry types in the geopackage.
query
(query[, outcolumns])Use a custom query on the geopackage to retrieve desired tables or joined information from multiple tables.
read_table
(table)Read all data in a specified table of the geopackage.
table_head
(table)Select the first five records from a table the in geopackage for quick inspection.