Features & attributes¶
Immutable geometry, property and ID snapshots, aligned selections, and exact Arrow values.
Related: Arrow & storage
Feature
¶
Accepted call forms
Feature(
geometry: NewFeatureG,
*,
properties: Mapping[str, FeatureScalarT],
id: NewFeatureId | None = None,
) -> Feature[NewFeatureG, FeatureScalarT, NewFeatureId]
Feature(
geometry: NewFeatureG,
*,
properties: Mapping[str, FeatureInput] | None = None,
id: NewFeatureId | None = None,
) -> Feature[NewFeatureG, FeatureValue, NewFeatureId]
Feature(
geometry: NewFeatureG,
*,
properties: Mapping[str, FeatureScalarT],
id: str | int | float | integer[Any] | floating[Any],
) -> Feature[NewFeatureG, FeatureScalarT, str | int | float]
Feature(
geometry: NewFeatureG,
*,
properties: Mapping[str, FeatureInput] | None = None,
id: str | int | float | integer[Any] | floating[Any],
) -> Feature[NewFeatureG, FeatureValue, str | int | float]
One immutable geometry, property and ID snapshot.
Create a feature snapshot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
NewFeatureG
|
The geometry, or |
required |
properties
|
Mapping[str, FeatureScalarT] | (Mapping[str, FeatureInput] | None)
|
Property values to snapshot recursively. |
varies by call form
|
id
|
NewFeatureId | None | (str | int | float | integer[Any] | floating[Any])
|
The optional feature identifier. Numeric IDs must be finite and boolean IDs are not accepted. |
varies by call form
|
Returns:
| Type | Description |
|---|---|
Feature
|
The immutable feature snapshot. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
GeometryError
|
If a numeric |
geometry
property
¶
geometry: FeatureG_co
The feature geometry.
Returns:
| Type | Description |
|---|---|
Geometry or None
|
The geometry, or |
id
property
¶
id: FeatureId_co | None
The explicit feature ID.
Returns:
| Type | Description |
|---|---|
(str, int, float or None)
|
The ID, or |
properties
property
¶
properties: Mapping[str, FeatureV_co] | None
The feature properties.
Returns:
| Type | Description |
|---|---|
mapping or None
|
Read-only values, or |
to_geojson
¶
to_geojson() -> str
Serialize this feature as an RFC 7946 GeoJSON Feature string.
Coordinate epoch metadata is not represented in GeoJSON Feature strings; the complete Space remains on the source feature.
Returns:
| Type | Description |
|---|---|
str
|
Compact RFC 7946 GeoJSON Feature JSON string. |
Raises:
| Type | Description |
|---|---|
InvalidGeometryError
|
If the geometry has an M ordinate or coordinates outside WGS 84 longitude/latitude bounds. |
CRSError
|
If a CRS-tagged geometry is not WGS 84 longitude/latitude. |
TypeError
|
If a property value is not JSON-serializable. |
Features
¶
Accepted call forms
Features(
geometries: GeometryArray[NewFeatureG] | Iterable[NewFeatureG],
properties: Mapping[str, FeatureScalarT]
| Iterable[Mapping[str, FeatureScalarT] | None],
ids: ndarray[Any, dtype[integer[Any] | floating[Any]]] | None = None,
) -> Features[NewFeatureG, FeatureScalarT, str | int | float]
Features(
geometries: GeometryArray[NewFeatureG] | Iterable[NewFeatureG],
properties: Mapping[str, FeatureInput]
| Iterable[Mapping[str, FeatureInput] | None]
| None = None,
ids: ndarray[Any, dtype[integer[Any] | floating[Any]]] = ...,
) -> Features[NewFeatureG, FeatureValue, str | int | float]
Features(
geometries: GeometryArray[NewFeatureG] | Iterable[NewFeatureG],
properties: Mapping[str, FeatureScalarT]
| Iterable[Mapping[str, FeatureScalarT] | None],
ids: Iterable[NewFeatureId | None] | None = None,
) -> Features[NewFeatureG, FeatureScalarT, NewFeatureId]
Features(
geometries: GeometryArray[NewFeatureG] | Iterable[NewFeatureG],
properties: Mapping[str, FeatureInput]
| Iterable[Mapping[str, FeatureInput] | None]
| None = None,
ids: Iterable[NewFeatureId | None] | None = None,
) -> Features[NewFeatureG, FeatureValue, NewFeatureId]
Features(
geometries: GeometryArray[NewFeatureG] | Iterable[NewFeatureG],
properties: Mapping[str, FeatureScalarT]
| Iterable[Mapping[str, FeatureScalarT] | None],
ids: Iterable[str | int | float | integer[Any] | floating[Any] | None],
) -> Features[NewFeatureG, FeatureScalarT, str | int | float]
Features(
geometries: GeometryArray[NewFeatureG] | Iterable[NewFeatureG],
properties: Mapping[str, FeatureInput]
| Iterable[Mapping[str, FeatureInput] | None]
| None = None,
ids: Iterable[str | int | float | integer[Any] | floating[Any] | None]
| None = None,
) -> Features[NewFeatureG, FeatureValue, str | int | float]
Immutable, row-aligned geometries, properties and feature IDs.
Build row-aligned feature columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometries
|
GeometryArray[NewFeatureG] | Iterable[NewFeatureG]
|
One geometry or |
required |
properties
|
Mapping[str, FeatureScalarT] | Iterable[Mapping[str, FeatureScalarT] | None] | (Mapping[str, FeatureInput] | Iterable[Mapping[str, FeatureInput] | None] | None)
|
A mapping or object with a callable |
varies by call form
|
ids
|
ndarray[Any, dtype[integer[Any] | floating[Any]]] | None | ndarray[Any, dtype[integer[Any] | floating[Any]]] | (Iterable[NewFeatureId | None] | None) | Iterable[str | int | float | integer[Any] | floating[Any] | None] | (Iterable[str | int | float | integer[Any] | floating[Any] | None] | None)
|
One string, non-boolean integer, finite float, or |
varies by call form
|
Returns:
| Type | Description |
|---|---|
Features
|
The geometry, property, and id columns aligned by input row. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a property input is not a mapping or row iterable, a property
key is not a string, or an id is not a string, non-boolean integer,
finite float, or |
GeometryError
|
If property or id rows do not match the geometry count, property keys repeat, or a numeric id is not finite. |
geometries
property
¶
geometries: GeometryArray[FeatureG_co]
The geometry column.
Returns:
| Type | Description |
|---|---|
GeometryArray
|
One parsed geometry or |
ids
property
¶
ids: Sequence[FeatureId_co | None]
The feature IDs.
Returns:
| Type | Description |
|---|---|
Sequence
|
Row-aligned IDs, with |
properties
property
¶
properties: Sequence[Mapping[str, FeatureV_co] | None]
The property rows.
Returns:
| Type | Description |
|---|---|
Sequence
|
Immutable row-aligned snapshots, with |
__getitem__
¶
Accepted call forms
__getitem__(
index: ndarray[tuple[()], dtype[signedinteger[Any] | unsignedinteger[Any]]],
/,
) -> Feature[FeatureG_co, FeatureV_co, FeatureId_co]
__getitem__(
index: ndarray[tuple[int], dtype[signedinteger[Any] | unsignedinteger[Any]]]
| ndarray[tuple[int], dtype[bool_]],
/,
) -> Features[FeatureG_co, FeatureV_co, FeatureId_co]
__getitem__(
index: ndarray[
tuple[int, ...], dtype[signedinteger[Any] | unsignedinteger[Any]]
],
/,
) -> (
Feature[FeatureG_co, FeatureV_co, FeatureId_co]
| Features[FeatureG_co, FeatureV_co, FeatureId_co]
)
__getitem__(
index: SupportsIndex, /
) -> Feature[FeatureG_co, FeatureV_co, FeatureId_co]
__getitem__(
index: slice | Sequence[bool] | Sequence[SupportsIndex], /
) -> Features[FeatureG_co, FeatureV_co, FeatureId_co]
Select a row or select aligned rows by slice, indices or mask.
__iter__
¶
__iter__() -> Iterator[Feature[FeatureG_co, FeatureV_co, FeatureId_co]]
Iterate feature rows in their current order.
column
¶
column(name: str) -> Sequence[FeatureV_co | None]
View a property column, using None for missing keys and rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The property name. |
required |
Returns:
| Type | Description |
|---|---|
Sequence
|
Row-aligned property values. |
from_columns
classmethod
¶
Accepted call forms
from_columns(
geometries: GeometryArray[NewFeatureG] | Iterable[NewFeatureG],
*,
columns: Mapping[str, Iterable[FeatureScalarT]],
ids: ndarray[Any, dtype[integer[Any] | floating[Any]]],
) -> Features[NewFeatureG, FeatureScalarT, str | int | float]
from_columns(
geometries: GeometryArray[NewFeatureG] | Iterable[NewFeatureG],
*,
columns: Mapping[str, Iterable[FeatureInput]],
ids: ndarray[Any, dtype[integer[Any] | floating[Any]]],
) -> Features[NewFeatureG, FeatureValue, str | int | float]
from_columns(
geometries: GeometryArray[NewFeatureG] | Iterable[NewFeatureG],
*,
columns: Mapping[str, Iterable[FeatureScalarT]],
ids: Iterable[NewFeatureId | None] | None = None,
) -> Features[NewFeatureG, FeatureScalarT, NewFeatureId]
from_columns(
geometries: GeometryArray[NewFeatureG] | Iterable[NewFeatureG],
*,
columns: Mapping[str, Iterable[FeatureInput]],
ids: Iterable[NewFeatureId | None] | None = None,
) -> Features[NewFeatureG, FeatureValue, NewFeatureId]
from_columns(
geometries: GeometryArray[NewFeatureG] | Iterable[NewFeatureG],
*,
columns: Mapping[str, Iterable[FeatureScalarT]],
ids: Iterable[str | int | float | integer[Any] | floating[Any] | None],
) -> Features[NewFeatureG, FeatureScalarT, str | int | float]
from_columns(
geometries: GeometryArray[NewFeatureG] | Iterable[NewFeatureG],
*,
columns: Mapping[str, Iterable[FeatureInput]],
ids: Iterable[str | int | float | integer[Any] | floating[Any] | None],
) -> Features[NewFeatureG, FeatureValue, str | int | float]
Build features from aligned named attribute columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometries
|
GeometryArray or iterable
|
One geometry or |
required |
columns
|
mapping
|
Property names and equally sized value columns. Inputs are
snapshotted so later changes cannot alter the features. Masked NumPy
cells in columns and IDs become |
required |
ids
|
iterable or None
|
Optional row-aligned feature IDs. |
None
|
Returns:
| Type | Description |
|---|---|
Features
|
The immutable, aligned feature collection. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If column names are not strings or inputs have unsupported types. |
GeometryError
|
If any column or |
materialize
¶
materialize() -> Features[FeatureG_co, FeatureV_co, FeatureId_co]
Detach selected geometry and properties from their parent storage.
Returns:
| Type | Description |
|---|---|
Features
|
A compact independent collection containing the selected rows. |
select_columns
¶
select_columns(names: Iterable[str]) -> Self
Return a feature collection containing the named properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
iterable of str
|
Property names to retain. |
required |
Returns:
| Type | Description |
|---|---|
Features
|
A new collection with the selected property columns. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
to_arrow
¶
to_arrow(
*,
geometry: str | None = None,
id_column: str | None = None,
encoding: Literal['auto', 'wkb'] = 'auto',
) -> PyArrowTable
Export a feature table, normalizing absent sparse properties to null.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
str or None
|
Geometry column name. |
None
|
id_column
|
str or None
|
ID column name. |
None
|
encoding
|
('auto', 'wkb')
|
Geometry encoding for the Arrow column. |
'auto'
|
Returns:
| Type | Description |
|---|---|
Table
|
A geometry-bearing Arrow table with aligned properties and IDs. |
Raises:
| Type | Description |
|---|---|
ModuleNotFoundError
|
If pyarrow is not installed. |
TypeError
|
If column names are not strings or a property column cannot be converted to Arrow. |
GeometryError
|
If |
to_geojson
¶
to_geojson() -> str
Serialize these features as an RFC 7946 GeoJSON FeatureCollection string.
Coordinate epoch metadata is not represented in GeoJSON FeatureCollection strings; the complete Space remains on the source features.
Returns:
| Type | Description |
|---|---|
str
|
Compact RFC 7946 GeoJSON FeatureCollection JSON string. |
Raises:
| Type | Description |
|---|---|
InvalidGeometryError
|
If a geometry has an M ordinate or coordinates outside WGS 84 longitude/latitude bounds. |
CRSError
|
If a CRS-tagged geometry is not WGS 84 longitude/latitude. |
TypeError
|
If a property value is not JSON-serializable. |
to_geopandas
¶
to_geopandas() -> GeoPandasDataFrame
Export aligned geometries, properties, and IDs as a GeoDataFrame.
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
GeoDataFrame with CRS retained from the geometry array. |
Raises:
| Type | Description |
|---|---|
ModuleNotFoundError
|
If geopandas is not installed. |
GeometryError
|
If a geometry column does not have Planar Space or if column names conflict. |
to_geoparquet
¶
to_geoparquet(
path: str | PathLike[str] | BinaryIO | PyArrowNativeFile,
*,
encoding: Literal['wkb', 'geoarrow', 'geometry'] = 'wkb',
**kwargs: Any,
) -> None
Write aligned geometries, properties and IDs as GeoParquet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
path - like or file - like
|
Destination accepted by PyArrow. |
required |
encoding
|
('wkb', 'geoarrow', 'geometry')
|
Geometry encoding. |
'wkb'
|
**kwargs
|
Any
|
Additional options passed to the Parquet writer. |
{}
|
Raises:
| Type | Description |
|---|---|
ModuleNotFoundError
|
If pyarrow is not installed. |
GeometryError
|
If encoding options or column names are invalid. |
to_pandas
¶
to_pandas(
*, geometry: str | None = None, id_column: str | None = None
) -> PandasDataFrame
Export aligned geometries, properties, and IDs as a pandas DataFrame.
Geometry columns use GeometryExtensionArray without copying native
storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
str or None
|
Geometry column name. |
None
|
id_column
|
str or None
|
ID column name. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame containing the geometry column, property columns, and optional feature ID column. |
Raises:
| Type | Description |
|---|---|
ModuleNotFoundError
|
If pandas is not installed. |
TypeError
|
If |
GeometryError
|
If |
to_polars
¶
to_polars(
*,
geometry: str | None = None,
id_column: str | None = None,
srids: Mapping[int, CrsInput] | None = None,
) -> PolarsDataFrame
Export aligned geometries, properties, and IDs as a Polars DataFrame.
Geometry columns are encoded as binary WKB/EWKB via
GeometryArray.to_polars.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
str or None
|
Geometry column name. |
None
|
id_column
|
str or None
|
ID column name. |
None
|
srids
|
Mapping[int, CRS - like]
|
Validate any emitted nonzero SRID in this destination namespace. A supplied mapping is exclusive; a missing identifier or CRS mismatch fails rather than falling back to EPSG or dropping the identifier. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame containing WKB/EWKB geometry columns, property columns, and optional feature ID column. |
Raises:
| Type | Description |
|---|---|
ModuleNotFoundError
|
If polars is not installed. |
TypeError
|
If |
GeometryError
|
If |
with_columns
¶
Accepted call forms
Add or replace aligned property columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
columns
|
mapping
|
Property names and value columns, each with one value per row. |
required |
Returns:
| Type | Description |
|---|---|
Features
|
A new collection with the supplied columns snapshotted. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If column names are not strings or values have unsupported types. |
GeometryError
|
If any column length does not match the feature count or a numeric column is not 1D. |
with_geometries
¶
with_geometries(
geometries: GeometryArray[NewFeatureG] | Iterable[NewFeatureG],
) -> Features[NewFeatureG, FeatureV_co, FeatureId_co]
Replace the geometry column while retaining aligned attributes and IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometries
|
GeometryArray or iterable
|
Replacement geometries, with the same number of rows. |
required |
Returns:
| Type | Description |
|---|---|
Features
|
A new collection sharing the existing properties and IDs. |
Raises:
| Type | Description |
|---|---|
GeometryError
|
If |
with_ids
¶
Accepted call forms
with_ids(
ids: ndarray[Any, dtype[integer[Any] | floating[Any]]],
) -> Features[FeatureG_co, FeatureV_co, str | int | float]
with_ids(
ids: Iterable[NewFeatureId | None] | None,
) -> Features[FeatureG_co, FeatureV_co, NewFeatureId]
with_ids(
ids: Iterable[str | int | float | integer[Any] | floating[Any] | None],
) -> Features[FeatureG_co, FeatureV_co, str | int | float]
Replace the feature IDs while retaining geometry and properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
iterable or None
|
One ID or |
required |
Returns:
| Type | Description |
|---|---|
Features
|
A new collection with the replacement IDs. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
GeometryError
|
If |
ArrowValue
¶
An immutable Arrow-backed property value.
Values retain their Arrow type and can be converted to a Python value or detached from the parent Arrow storage.
type
property
¶
type: str
The Arrow data type.
Returns:
| Type | Description |
|---|---|
str
|
The Arrow data type as a string. |
value
property
¶
value: int
The integer value of a temporal Arrow scalar.
Returns:
| Type | Description |
|---|---|
int
|
The value in the Arrow type's native units. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the Arrow value is not temporal. |
as_py
¶
as_py() -> Any
Convert this value to its Python representation.
Returns:
| Type | Description |
|---|---|
object
|
The converted value. |
materialize
¶
materialize() -> ArrowValue
Detach this value from its parent Arrow storage.
Returns:
| Type | Description |
|---|---|
ArrowValue
|
An independently owned value with the same Arrow type. |