mufasa.io.outputs.geojson#

Classes#

GeoJsonOutput

Writes collected Observations or Locations to a GeoJSON file (WGS84).

Module Contents#

class mufasa.io.outputs.geojson.GeoJsonOutput(path: str)#

Bases: mufasa.io.outputs.base.OutputNode

Writes collected Observations or Locations to a GeoJSON file (WGS84).

All properties from Location.properties are included. For Observation objects, confidence and timestamp are additionally written as top-level feature properties.

Override encode() in a subclass to serialise richer types (e.g. UncertainObservation) to custom GeoJSON properties.

Parameters:

path (str)

path#
configure(crs, bbox, resolution) → None#

Receive spatial configuration from the Graph at construction time.

Override in nodes that need crs/bbox/resolution to initialise internal state (e.g. POM creates its map here). Default is a no-op.

Return type:

None

encode(loc: mufasa.location.Location) → dict#

Convert a Location or Observation to a GeoJSON feature dict.

Geometry is reprojected to WGS84 (accessible via self._reproject). Override in a subclass to serialise additional typed fields.

Parameters:

loc (mufasa.location.Location)

Return type:

dict

process(loc: mufasa.location.Location) → None#

Process incoming data and forward results to successors.

Override with the signature appropriate for this node’s role:

Observation-consuming nodes receive one observation per call:

def process(self, obs: Observation) -> None:
    result = ...                    # compute result
    for succ in self._successors:
        succ.process(result)        # push to downstream nodes

Map-consuming nodes are called with no arguments and read their input from the predecessor via its .map attribute:

def process(self) -> None:
    m = self._predecessors[0].map   # read upstream map
    ...                             # update self.map in place
    self._trigger_successors()      # notify downstream nodes

Sink nodes collect data without emitting anything further:

def process(self, obs: Observation) -> None:
    self._collected.append(obs)
Parameters:

loc (mufasa.location.Location)

Return type:

None

reset() → None#

Clear all runtime state, returning the node to its post-init condition.

Called by the framework between pipeline runs so the same node instance can process a fresh dataset without being reconstructed. Override in nodes that hold mutable state (buffers, accumulators, fitted models). The default is a no-op — stateless nodes need not override this.

Return type:

None

save() → None#

Persist any buffered output to its destination.

No-op by default. Subclasses that buffer results (GeoJsonOutput, GeoTiffOutput, etc.) override this to flush to disk. Called by Graph.run() after all inputs have been processed.

Return type:

None

get_config() → dict#

Return all constructor arguments as a plain JSON-serializable dict.

Used by Graph.to_config() to serialise the pipeline. Every key must be a string; every value must be JSON-serializable.

Return type:

dict