open_file
Luo_Suppe2026-08-15
gma.gio.open_file
[function] open_file(in_src, flag = None, allowed_drivers = [], open_options = [], sibling_files = []):Open a raster or vector file as a Dataset.
Parameters:
in_src: str.
Name of the file to open.
Optional:
flag = int||None. Default None.
Flag controlling how the Dataset is opened. None for auto.
allowed_drivers = list. Default [].
A list of the names of drivers that may attempt to open.
open_options = dict/list. Default [].
A dict or list of name=value driver-specific opening options.
sibling_files = list. Default [].
A list of filenames that are auxiliary to the main filename.
Returns:
Type: GeoDatabase.
Example
from gma import gio
gdb = gio.open_file('NewGDB.gpkg') # the sample GeoPackage
print(type(gdb).__name__, gdb.driver)
print('layers :', gdb.layer_names)
print('features:', [len(gdb.get_layer(i)) for i in range(gdb.layer_count)])
GeoDatabase GPKG - Vector
layers : ['New_Australia', 'Australia']
features: [18, 9]