API Documentation¶
Reader¶
- class papotch.reader.Reader(uri: str | Path | bytes, layer: int | str | None = None, encoding: str | None = None, columns: str | Sequence[str] | None = None, where: str | None = None, max_features: int | None = None, bbox: tuple[float, float, float, float] | None = None, **kwargs)¶
Class extracting Data using the polars_st read_file() function.
- Parameters:
uri (str | Path | bytes) – Path to the data source
layer (int | str | None = None) – Index or name of the layer to read
encoding (str | None = None) – Data encoding
columns (str | Sequence[str] | None = None) – Column(s) to read from the source
where (str | None = None) – SQL condition to filter data
max_features – Maximum number of features to read
bbox (tuple[float, float, float, float] | None = None) – Bounding box spatially filtering read data
- extract(active_geometry: str = 'geometry') Data¶
Extract data using the polars_st read_file() function.
- Parameters:
active_geometry (str) – Active geometry name of the returned Data. Default to “geometry”
- property bbox: tuple[float, float, float, float] | None¶
- property columns: str | Sequence[str] | None¶
- property encoding: str | None¶
- property layer: int | str | None¶
- property max_features: int | None¶
- property uri: str | Path | bytes¶
- property where: str | None¶
Data¶
- class papotch.data.Data(df: DataFrame, active_geometry: str = 'geometry')¶
The central class holding the data.
This is a thin wrapper around a polars DataFrame, passed from polars_st.
- Parameters:
df (polars.DataFrame) – The DataFrame to be processed.
active_geometry (str) – The current geometry column used for the processing.
- area(column_name: str = '_area') None¶
- bounds(column_name: str = '_bounds') None¶
- clone()¶
- collect(into: Literal['Unknown', 'Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon', 'GeometryCollection', 'CircularString', 'CompoundCurve', 'CurvePolygon', 'MultiCurve', 'MultiSurface', 'Curve', 'Surface', 'PolyhedralSurface', 'Tin', 'Triangle'] | None = None) Data¶
- coordinate_dimension(column_name: str = '_coord_dim') None¶
- coordinates(column_name: str = '_coord') None¶
- count_coordinates(column_name: str = '_n_coord') None¶
- count_geometries(column_name: str = '_n_geom') None¶
- count_interior_rings(column_name: str = '_n_rings') None¶
- count_points(column_name: str = '_n_points') None¶
- dimensions(column_name: str = '_dimensions') None¶
- explore()¶
- geometry_type(column_name: str = '_geom_type') None¶
- group_by_attributes(columns: Sequence[str], geom_agg: Literal['coverage_union', 'union', 'difference', 'symmetric_difference', 'collect', 'intersection', 'total_bounds'] = 'coverage_union')¶
- head(n: int = 5) None¶
Print the first lines of Data.
- Parameters:
n (int) – The number of rows to print
- interior_rings(column_name: str = '_int_rings') None¶
- length(column_name: str = '_length') None¶
- m(column_name: str = '_m') None¶
- minimum_clearance(column_name: str = '_min_clear') None¶
- offset_curve(distance: float, quad_segs: int = 8, join_style: Literal['round', 'mitre', 'bevel'] = 'round', mitre_limit: float = 5.0) Data¶
- plot(**kwargs)¶
- precision(column_name: str = '_precision') None¶
- scale(x: float, y: float, z: float, origin: Literal['center', 'centroid'] | Sequence[float] = 'center') Data¶
- set_precision(grid_size: float, mode: Literal['valid_output', 'no_topo', 'keep_collapsed'] = 'valid_output') Data¶
- skew(x: float, y: float, z: float, origin: Literal['center', 'centroid'] | Sequence[float] = 'center') Data¶
- tail(n: int = 5) None¶
Print the last lines of Data.
- Parameters:
n (int) – The number of rows to print
- voronoi_polygons(tolerance: float = 0.0, extend_to: bytes | None = None, only_edges: bool = False) Data¶
- write(path: str, layer: str, driver: str, **kwargs) None¶
- write_geojson(path: str, **kwargs) None¶
- write_gpkg(path: str, layer: str | None = '_layer', **kwargs) None¶
- write_postgis(uri: str, layer: str, **kwargs) None¶
- write_shapefile(path: str, **kwargs) None¶
- x(column_name: str = '_x') None¶
- y(column_name: str = '_y') None¶
- z(column_name: str = '_z') None¶
- property active_geometry: str¶
Return the name of the active geometry.
- Returns:
The name of the active geometry
- Return type:
str
- property df: DataFrame¶
Return the underlying DataFrame.
- Returns:
The polars DataFrame hosting the data
- Return type:
polars.DataFrame
- property extent: Data¶
Return the extent of the DataFrame.
- Returns:
A Data with a single rectangle geometry
- Return type:
- property schema: dict¶
Return the schema of the Data instance.
- Returns:
The dictionnary of the field names and types
- Return type:
dict
- property shape: tuple[int, int]¶
Return the shape of the Data instance.
- Returns:
The number of lines and columns of the Data
- Return type:
tuple[int, int]