Skip to content

Commit

Permalink
Split pyi typing for io module
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Dec 6, 2024
1 parent 0eac101 commit e35e12c
Show file tree
Hide file tree
Showing 6 changed files with 515 additions and 478 deletions.
35 changes: 35 additions & 0 deletions python/geoarrow-io/python/geoarrow/rust/io/_csv.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from pathlib import Path
from typing import BinaryIO

from arro3.core import Table
from arro3.core.types import ArrowStreamExportable

def read_csv(
file: str | Path | BinaryIO,
geometry_column_name: str,
*,
batch_size: int = 65536,
) -> Table:
"""
Read a CSV file from a path on disk into a Table.
Args:
file: the path to the file or a Python file object in binary read mode.
geometry_column_name: the name of the geometry column within the CSV.
batch_size: the number of rows to include in each internal batch of the table.
Returns:
Table from CSV file.
"""

def write_csv(table: ArrowStreamExportable, file: str | Path | BinaryIO) -> None:
"""
Write a Table to a CSV file on disk.
Args:
table: the Arrow RecordBatch, Table, or RecordBatchReader to write.
file: the path to the file or a Python file object in binary write mode.
Returns:
None
"""
70 changes: 70 additions & 0 deletions python/geoarrow-io/python/geoarrow/rust/io/_geojson.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from __future__ import annotations

from pathlib import Path
from typing import BinaryIO, Union

from arro3.core import Table
from arro3.core.types import ArrowStreamExportable

def read_geojson(file: Union[str, Path, BinaryIO], *, batch_size: int = 65536) -> Table:
"""
Read a GeoJSON file from a path on disk into an Arrow Table.
Args:
file: the path to the file or a Python file object in binary read mode.
batch_size: the number of rows to include in each internal batch of the table.
Returns:
Table from GeoJSON file.
"""

def read_geojson_lines(
file: Union[str, Path, BinaryIO], *, batch_size: int = 65536
) -> Table:
"""
Read a newline-delimited GeoJSON file from a path on disk into an Arrow Table.
This expects a GeoJSON Feature on each line of a text file, with a newline character separating
each Feature.
Args:
file: the path to the file or a Python file object in binary read mode.
batch_size: the number of rows to include in each internal batch of the table.
Returns:
Table from GeoJSON file.
"""

def write_geojson(
table: ArrowStreamExportable, file: Union[str, Path, BinaryIO]
) -> None:
"""
Write to a GeoJSON file on disk.
Note that the GeoJSON specification mandates coordinates to be in the WGS84 (EPSG:4326)
coordinate system, but this function will not automatically reproject into WGS84 for you.
Args:
table: the Arrow RecordBatch, Table, or RecordBatchReader to write.
file: the path to the file or a Python file object in binary write mode.
Returns:
None
"""

def write_geojson_lines(
table: ArrowStreamExportable, file: Union[str, Path, BinaryIO]
) -> None:
"""
Write to a newline-delimited GeoJSON file on disk.
Note that the GeoJSON specification mandates coordinates to be in the WGS84 (EPSG:4326)
coordinate system, but this function will not automatically reproject into WGS84 for you.
Args:
table: the Arrow RecordBatch, Table, or RecordBatchReader to write.
file: the path to the file or a Python file object in binary write mode.
Returns:
None
"""
Loading

0 comments on commit e35e12c

Please sign in to comment.