Skip to main content

DataSource

Wraps an OGR Data Source object.

Attributes

AttributeTypeDescription
destructorcallable = capi.destroy_dsThe GDAL C API function used to destroy the OGR Data Source object and release its resources.
encodingstring = utf-8The character encoding used for string data within the data source, defaulting to 'utf-8'.
ptrpointerThe underlying pointer to the OGR Data Source object managed by this class.
driver[Driver](../driver/driver.md?sid=django_contrib_gis_gdal_driver_driver)The GDAL Driver instance used to open and manage this specific data source.
layer_countintegerReturn the number of layers in the data source.
namestringReturn the name of the data source.

Constructor

Signature

def DataSource(
ds_input: str, Path, or pointer,
ds_driver: Driver pointer = False,
write: boolean = False,
encoding: string = "utf-8"
)

Parameters

NameTypeDescription
ds_inputstr, Path, or pointerThe input data source, which can be a file path (string or Path object) or a raw pointer to an existing data source.
ds_driverDriver pointer = FalseAn optional driver pointer used when initializing from an existing data source pointer.
writeboolean = FalseA flag indicating whether to open the data source in update mode (True) or read-only mode (False).
encodingstring = "utf-8"The character encoding to use for the data source.

Methods


layer_count()

@classmethod
def layer_count() - > int

Return the number of layers in the data source.

Returns

TypeDescription
intThe integer count of layers present in the data source.

name()

@classmethod
def name() - > str

Return the name of the data source.

Returns

TypeDescription
strThe file path or connection string name of the data source, decoded using the instance encoding.