dicogis.georeaders.base_georeader module

class dicogis.georeaders.base_georeader.GeoReaderBase(dataset_type, localized_strings=None)

Bases: object

Base class for geographic dataset readers.

__init__(dataset_type, localized_strings=None)

Initialization.

Parameters:
  • dataset_type (Literal['flat_cad', 'flat_database', 'flat_database_esri', 'flat_raster', 'flat_vector', 'sgbd_postgis']) – type of dataset to read

  • localized_strings (Optional[dict]) – translated strings

calc_size_full_dataset(source_path, dependencies=None)

Calculate size of dataset and its dependencies.

Parameters:
  • source_path (str) – path to the dataset or a folder.

  • dependencies (list, optional) – list of dataset’s dependencies. Defaults to None.

Returns:

size in octets

Return type:

int

erratum(target_container, src_path=None, src_dataset_layer=None, err_type=1, err_msg='')

Store error messages in container object.

Parameters:
  • target_container (Union[dict, MetaDataset]) – object where to store error message and type

  • src_path (Optional[str], optional) – source path. Defaults to None.

  • src_dataset_layer (Optional[ogr.Layer], optional) – source dataset layer. Defaults to None.

  • err_type (int, optional) – _description_. Defaults to 1.

  • err_msg (str, optional) – _description_. Defaults to “”.

get_extent_as_tuple(dataset_or_layer)

Get spatial extent (bounding box).

Return type:

tuple[Optional[float], Optional[float], Optional[float], Optional[float]]

get_fields_details(ogr_layer_definition)

Get feature attributes from layer definition.

Return type:

tuple[AttributeField]

get_geometry_type(layer)

Get geometry type for a given ogr layer.

Parameters:

layer (Layer) – OGR layer

Return type:

str | None

Returns:

geometry type or None

get_srs_details(dataset_or_layer)

Get coordinates system name, type and registry code.

Parameters:

dataset_or_layer (Union[ogr.Layer, gdal.Dataset]) – input dataset or OGR layer

Return type:

tuple[str, str, str, str]

Returns:

crs_name, crs_registry, crs_code, crs_type

get_srs_name(object_spatial_reference)

Get SRS name from an osr object.

Parameters:

object_spatial_reference (SpatialReference) – osr object. Typically obtained with ogr.Layer.GetSpatialReference()

Return type:

str

Returns:

name of spatial reference

get_srs_type(object_spatial_reference)

Get SRS type from an osr object.

Parameters:

object_spatial_reference (SpatialReference) – osr object. Typically obtained with ogr.Layer.GetSpatialReference()

Return type:

str

Returns:

type of spatial reference

list_dependencies(main_dataset)

List dependant files around a main file.

Parameters:

main_dataset (Union[Path, str, Dataset]) – gdal.Dataset or ogr.Layer or path to the source dataset

Return type:

list[Path]

Returns:

list of file paths related to the main dataset

open_dataset_with_gdal(source_dataset)

Open dataset with GDAL (OGR).

Parameters:

source_dataset (Union[Path, str]) – path or connection string to the dataset

Returns:

opened dataset

Return type:

gdal.Dataset