Readers#

The readers module provides functions for reading geospatial data from various sources.

libadalina_core.readers.csv_to_dataframe(file_path: str, separator=None) DataFrame[source]#

Read a CSV file and return a pandas DataFrame.

Parameters:
  • file_path (str) – Path to the CSV file.

  • separator (str) – The separator used in the CSV file. If None, the separator will be detected automatically.

Returns:

The DataFrame containing the CSV data.

Return type:

pd.DataFrame

Raises:

FileNotFoundError – If the specified file does not exist.

libadalina_core.readers.geopackage_to_dataframe(path: str, layer: str | None = None) GeoDataFrame[source]#

Read a GeoPackage file into a GeoDataFrame.

Geometry is automatically converted to the libadalina default EPSG DEFAULT_EPSG.

Parameters:
  • path (str) – The path to the GeoPackage file.

  • layer (str) – The layer name of the GeoPackage. If None, the first layer found will be used.

Returns:

A GeoDataFrame containing the data from the specified layer.

Return type:

geopandas.GeoDataFrame

Examples

>>> gdf = geopackage_to_dataframe('data.gpkg', 'layer_name')
libadalina_core.readers.read_dataset(dataset_path: str) DataFrame | GeoDataFrame | DataFrame[source]#

Read a dataset from a file, supporting both GeoPackage (.gpkg) and CSV (.csv) formats.

Parameters:

dataset_path (str) – Path to the dataset file

Returns:

The loaded dataset as a DataFrame

Return type:

DataFrame