popframe.models.geodataframe
Classes
|
Abstract base class for data validation in a GeoDataFrame, designed to be inherited by other classes. |
|
Custom GeoDataFrame class that extends geopandas.GeoDataFrame and supports data validation with Pydantic's BaseModel. |
- class popframe.models.geodataframe.BaseRow(*, geometry: BaseGeometry, index: int)[source]
Bases:
BaseModel
,ABC
Abstract base class for data validation in a GeoDataFrame, designed to be inherited by other classes.
Attributes
- model_configConfigDict
Configuration for allowing arbitrary types in Pydantic validation.
- geometryBaseGeometry
Geometry attribute for storing shapely geometries.
- indexint
Index attribute, can be overridden, but shouldn’t be set by default.
Notes
Inheriting classes can be configured to provide default column values to avoid None and NaN.
- geometry: BaseGeometry
- index: int
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- class popframe.models.geodataframe.GeoDataFrame(data, *args)[source]
Bases:
GeoDataFrame
,BaseModel
,Generic
[T
]Custom GeoDataFrame class that extends geopandas.GeoDataFrame and supports data validation with Pydantic’s BaseModel. This class allows for the automatic validation of data on initialization using a generic class T inherited from BaseRow.
Attributes
- genericproperty
A property to access the generic class used in the GeoDataFrame.
Methods
Parameters
Notes
The provided generic class (T) must be a subclass of BaseRow for validation.
If the input data is not already a GeoDataFrame, it will be converted into one.
The “index” column is managed separately to avoid conflicts with the GeoDataFrame’s index.
The coordinate reference system (CRS) is either provided in the kwargs or inherited from the input data.
- property generic
Returns the generic class type used in the GeoDataFrame. This is needed to ensure Pydantic validation is performed correctly.
Returns
- TType
The type of the generic class used for row validation.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.