core_lens.export.formats#
Module for Core Lens.
Functions#
|
Export the result data to a standard Parquet file. |
|
Export the result data to a standard JSON file. |
|
Export the result data to a standard CSV file. |
|
Export the result data to a GeoParquet file. |
|
Export the result data to a GeoJSON file. |
Module Contents#
- core_lens.export.formats.parquet(result: core_lens.base.result.Result, path: str | pathlib.Path, **kwargs: Any) None#
Export the result data to a standard Parquet file.
This function uses Polars to write the underlying data frame.
- Parameters:
result (Result) – The Result object to export.
path (str | pathlib.Path) – Destination path for the Parquet file.
**kwargs (Any) – Additional options to pass to Polars write_parquet.
- Raises:
TypeError – If the Result object has geometry.
Example
>>> from core_lens.export import parquet >>> parquet(result, "output.parquet", compression="zstd", compression_level=3)
- core_lens.export.formats.json(result: core_lens.base.result.Result, path: str | pathlib.Path, **kwargs: Any) None#
Export the result data to a standard JSON file.
This function uses Polars to write the underlying data frame.
- Parameters:
result (Result) – The Result object to export.
path (str | pathlib.Path) – Destination path for the JSON file.
**kwargs (Any) – Additional options to pass to Polars write_json.
- Raises:
TypeError – If the Result object has geometry.
Example
>>> from core_lens.export import json >>> json(result, "output.json", pretty=True)
- core_lens.export.formats.csv(result: core_lens.base.result.Result, path: str | pathlib.Path, **kwargs: Any) None#
Export the result data to a standard CSV file.
This function uses Polars to write the underlying data frame.
- Parameters:
result (Result) – The Result object to export.
path (str | pathlib.Path) – Destination path for the CSV file.
**kwargs (Any) – Additional options to pass to Polars write_csv.
- Raises:
TypeError – If the Result object has geometry.
Example
>>> from core_lens.export import csv >>> csv(result, "output.csv", separator=",")
- core_lens.export.formats.geoparquet(result: core_lens.base.result.Result, path: str | pathlib.Path, **kwargs: Any) None#
Export the result data to a GeoParquet file.
This function uses DuckDB to write the data frame with spatial extensions.
- Parameters:
result (Result) – The Result object to export.
path (str | pathlib.Path) – Destination path for the GeoParquet file.
**kwargs (Any) – Additional options to pass to DuckDB’s COPY statement.
Example
>>> from core_lens.export import geoparquet >>> geoparquet( ... result.with_geometry(), ... "output.geoparquet", ... compression="ZSTD", ... partition_by="year" ... )
- Raises:
TypeError – If the Result object does not have geometry.
- core_lens.export.formats.geojson(result: core_lens.base.result.Result, path: str | pathlib.Path, **kwargs: Any) None#
Export the result data to a GeoJSON file.
This function natively streams the data directly from Polars and Shapely without invoking GDAL or DuckDB, making it fast for large datasets.
- Parameters:
result (Result) – The Result object to export.
path (str | pathlib.Path) – Destination path for the GeoJSON file.
**kwargs (Any) – Driver-specific kwargs are currently ignored. The driver keyword argument supports GeoJSONSeq for newline-delimited GeoJSON.
Example
>>> from core_lens.export import geojson >>> geojson(result.with_geometry(), "output.json")
- Raises:
TypeError – If the Result object does not have geometry.