ValidROICollectionGeoJSON#

class movement.validators.files.ValidROICollectionGeoJSON(file)[source]#

Bases: object

Class for validating GeoJSON FeatureCollection files.

The validator ensures that the file:

  • is well-formed JSON.

  • conforms to the RoI Collection GeoJSON schema, which checks that the file contains a GeoJSON FeatureCollection containing movement-compatible regions of interest (as produced by save_rois()).

Additionally, it performs a custom validation step to ensure that each Feature’s roi_type property is consistent with its geometry type (e.g. “PolygonOfInterest” must have geometry type “Polygon”).

Raises:
  • ValueError – If the file is not valid JSON or does not match the expected schema.

  • TypeError – If roi_type property does not match the actual geometry type.

See also

movement.roi.save_rois

Save a collection of RoIs to a GeoJSON file.

movement.roi.load_rois

Load a collection of RoIs from a GeoJSON file.

data: dict#

Parsed JSON data from the file, available after validation.

file: Path#

Path to the GeoJSON file to validate.

schema: ClassVar[Mapping[str, Any]] = {'$schema': 'https://json-schema.org/draft/2020-12/schema', 'description': 'Schema for validating GeoJSON FeatureCollection files containing RoIs', 'properties': {'features': {'items': {'properties': {'geometry': {'properties': {'coordinates': {'type': 'array'}, 'type': {'enum': ['Polygon', 'LineString', 'LinearRing']}}, 'required': ['type', 'coordinates'], 'type': 'object'}, 'properties': {'oneOf': [{'type': 'null'}, {'properties': {'name': {'type': 'string'}, 'roi_type': {'enum': ['PolygonOfInterest', 'LineOfInterest']}}, 'type': 'object'}]}, 'type': {'const': 'Feature'}}, 'required': ['type', 'geometry'], 'type': 'object'}, 'type': 'array'}, 'type': {'const': 'FeatureCollection'}}, 'required': ['type', 'features'], 'title': 'RoI Collection GeoJSON', 'type': 'object'}#

JSON schema for validating the structure of the GeoJSON file.

suffixes: ClassVar[set[str]] = {'.geojson', '.json'}#

Expected suffix(es) for the file.