Pydantic Models for MicroJSON and GeoJSON
Introduction
This document describes the Pydantic models used for GeoJSON and MicroJSON objects. These models leverage Python's type hinting and Pydantic's validation mechanisms, making it robust and efficient to work with complex GeoJSON and MicroJSON objects.
Models
MicroJSON and GeoJSON models, defined manually using pydantic.
Axis
Bases: BaseModel
An axis of a coordinate system
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
StrictStr
|
The name of the axis |
required |
type
|
Optional[AxisType]
|
The type of the axis |
required |
unit
|
Optional[Unit]
|
The unit of the axis |
required |
description
|
Optional[str]
|
A description of the axis |
required |
Source code in src/microjson/model.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
AxisType
Bases: Enum
The type of an axis
Source code in src/microjson/model.py
68 69 70 71 72 73 |
|
CoordinateTransformation
Bases: BaseModel
Coordinate transformation abstract class harmonized with the OME model
Source code in src/microjson/model.py
92 93 94 |
|
GeoJSON
Bases: RootModel
The root object of a GeoJSON file
Source code in src/microjson/model.py
28 29 30 31 |
|
Identity
Bases: CoordinateTransformation
Identity transformation for coordinates
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type
|
Literal['identity']
|
The type of the transformation |
required |
Source code in src/microjson/model.py
97 98 99 100 101 102 103 104 |
|
MicroFeature
Bases: Feature
A MicroJSON feature, which is a GeoJSON feature with additional metadata
Parameters:
Name | Type | Description | Default |
---|---|---|---|
multiscale
|
Optional[Multiscale]
|
The coordinate system of the feature |
required |
ref
|
Optional[Union[StrictStr, StrictInt]]
|
A reference to the parent feature |
required |
parentId
|
Optional[Union[StrictStr, StrictInt]]
|
A reference to the parent feature |
required |
featureClass
|
Optional[str]
|
The class of the feature |
required |
Source code in src/microjson/model.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
MicroFeatureCollection
Bases: FeatureCollection
A MicroJSON feature collection, which is a GeoJSON feature collection with additional metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
properties
|
Optional[Props]
|
The properties of the feature collection |
required |
id
|
Optional[Union[StrictStr, StrictInt]]
|
The ID of the feature collection |
required |
provenance
|
Optional[Union[Workflow, WorkflowCollection, Artifact, ArtifactCollection]]
|
The provenance of the feature collection |
required |
Source code in src/microjson/model.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
MicroJSON
Bases: RootModel
The root object of a MicroJSON file
Source code in src/microjson/model.py
185 186 187 188 189 190 |
|
Multiscale
Bases: BaseModel
A coordinate system for MicroJSON coordinates
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axes
|
List[Axis]
|
The axes of the coordinate system |
required |
coordinateTransformations
|
Optional[List[CoordinateTransformation]]
|
A list of coordinate transformations |
required |
transformationMatrix
|
Optional[List[List[float]]
|
The transformation matrix |
required |
Source code in src/microjson/model.py
131 132 133 134 135 136 137 138 139 140 141 142 |
|
Scale
Bases: CoordinateTransformation
Scale transformation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type
|
Literal['scale']
|
The type of the transformation |
required |
scale
|
List[float]
|
The scale vector |
required |
Source code in src/microjson/model.py
119 120 121 122 123 124 125 126 127 128 |
|
Translation
Bases: CoordinateTransformation
Translation transformation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type
|
Literal['translation']
|
The type of the transformation |
required |
translation
|
List[float]
|
The translation vector |
required |
Source code in src/microjson/model.py
107 108 109 110 111 112 113 114 115 116 |
|
Unit
Bases: Enum
A unit of measurement
Source code in src/microjson/model.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
Base Objects
Geometry Types
Uses geojson-pydantic models for GeoJSON geometry types, included here for reference. Please refer to the geojson-pydantic documentation for more information.
Point
Represents a GeoJSON Point object.
MultiPoint
Represents a GeoJSON MultiPoint object.
LineString
Represents a GeoJSON LineString object.
MultiLineString
Represents a GeoJSON MultiLineString object.
Polygon
Represents a GeoJSON Polygon object.
MultiPolygon
Represents a GeoJSON MultiPolygon object.
Compound Objects
Multiscale
A coordinate system for MicroJSON features or feature collections.
Bases: BaseModel
A coordinate system for MicroJSON coordinates
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axes
|
List[Axis]
|
The axes of the coordinate system |
required |
coordinateTransformations
|
Optional[List[CoordinateTransformation]]
|
A list of coordinate transformations |
required |
transformationMatrix
|
Optional[List[List[float]]
|
The transformation matrix |
required |
Source code in src/microjson/model.py
131 132 133 134 135 136 137 138 139 140 141 142 |
|
GeometryCollection
A coordinate system for MicroJSON features or feature collections.
Bases: BaseModel
A coordinate system for MicroJSON coordinates
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axes
|
List[Axis]
|
The axes of the coordinate system |
required |
coordinateTransformations
|
Optional[List[CoordinateTransformation]]
|
A list of coordinate transformations |
required |
transformationMatrix
|
Optional[List[List[float]]
|
The transformation matrix |
required |
Source code in src/microjson/model.py
131 132 133 134 135 136 137 138 139 140 141 142 |
|
GeometryCollection
A collection of multiple geometries. From geojson-pydantic(https://developmentseed.org/geojson-pydantic/), included here for reference.
Feature
Represents a GeoJSON feature object, from geojson-pydantic(https://developmentseed.org/geojson-pydantic/), included here for reference.
FeatureCollection
Represents a GeoJSON feature collection, from geojson-pydantic(https://developmentseed.org/geojson-pydantic/), included here for reference.
GeoJSON
The root object of a GeoJSON file.
Bases: RootModel
The root object of a GeoJSON file
Source code in src/microjson/model.py
28 29 30 31 |
|
MicroJSON Extended Models
MicroFeature
A MicroJSON feature, which is an extension of a GeoJSON feature.
Bases: Feature
A MicroJSON feature, which is a GeoJSON feature with additional metadata
Parameters:
Name | Type | Description | Default |
---|---|---|---|
multiscale
|
Optional[Multiscale]
|
The coordinate system of the feature |
required |
ref
|
Optional[Union[StrictStr, StrictInt]]
|
A reference to the parent feature |
required |
parentId
|
Optional[Union[StrictStr, StrictInt]]
|
A reference to the parent feature |
required |
featureClass
|
Optional[str]
|
The class of the feature |
required |
Source code in src/microjson/model.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
MicroFeatureCollection
A MicroJSON feature collection, which is an extension of a GeoJSON feature collection.
Bases: FeatureCollection
A MicroJSON feature collection, which is a GeoJSON feature collection with additional metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
properties
|
Optional[Props]
|
The properties of the feature collection |
required |
id
|
Optional[Union[StrictStr, StrictInt]]
|
The ID of the feature collection |
required |
provenance
|
Optional[Union[Workflow, WorkflowCollection, Artifact, ArtifactCollection]]
|
The provenance of the feature collection |
required |
Source code in src/microjson/model.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
MicroJSON
The root object of a MicroJSON file.