Skip to content

earthlib.metadata

Metadata specification for VIPER tools tables.

Schema dataclass

Base class for defining EO sensor specifications.

Source code in earthlib/metadata.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
@dataclass
class Schema:
    """Base class for defining EO sensor specifications."""

    # unique ID for the measured spectrum
    NAME: str

    # the following are hierarchical land cover classification levels
    LEVEL_1: Literal["pervious", "impervious"]
    LEVEL_2: Literal["bare", "burn", "npv", "urban", "vegetation"]
    LEVEL_3: Literal["measured", "simulated"] = "measured"
    LEVEL_4: str | None = None

    # geographic location data
    LAT: float | None = None
    LON: float | None = None

    # data source
    SOURCE: str | None = None

    # additional notes about the sample
    NOTES: str | None = None

    def copy(self) -> "Schema":
        """Returns a copy of the schema object."""
        return Schema(**asdict(self))

copy()

Returns a copy of the schema object.

Source code in earthlib/metadata.py
32
33
34
def copy(self) -> "Schema":
    """Returns a copy of the schema object."""
    return Schema(**asdict(self))

to_dataframe(schemas)

Converts a list of Schema objects to a pandas DataFrame.

Source code in earthlib/metadata.py
37
38
39
def to_dataframe(schemas: Iterable[Schema]):
    """Converts a list of Schema objects to a pandas DataFrame."""
    return pd.DataFrame([asdict(s) for s in schemas])