DataSource
Wraps an OGR Data Source object.
Attributes
| Attribute | Type | Description |
|---|---|---|
| destructor | callable = capi.destroy_ds | The GDAL C API function used to destroy the OGR Data Source object and release its resources. |
| encoding | string = utf-8 | The character encoding used for string data within the data source, defaulting to 'utf-8'. |
| ptr | pointer | The 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_count | integer | Return the number of layers in the data source. |
| name | string | Return 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
| Name | Type | Description |
|---|---|---|
| ds_input | str, Path, or pointer | The input data source, which can be a file path (string or Path object) or a raw pointer to an existing data source. |
| ds_driver | Driver pointer = False | An optional driver pointer used when initializing from an existing data source pointer. |
| write | boolean = False | A flag indicating whether to open the data source in update mode (True) or read-only mode (False). |
| encoding | string = "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
| Type | Description |
|---|---|
int | The integer count of layers present in the data source. |
name()
@classmethod
def name() - > str
Return the name of the data source.
Returns
| Type | Description |
|---|---|
str | The file path or connection string name of the data source, decoded using the instance encoding. |