Datasets:

Modalities:
Geospatial
Languages:
English
DOI:
Libraries:
License:
File size: 4,908 Bytes
7b125af
1b5eb4d
7b125af
f8b9396
7b125af
1b5eb4d
 
 
 
7b125af
1b5eb4d
 
 
7b125af
1b5eb4d
7b125af
1b5eb4d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b125af
1b5eb4d
 
 
 
 
 
 
 
 
 
 
 
 
 
7b125af
 
 
2ec1597
 
 
1ad66f1
0ed8292
 
 
d22a000
0ed8292
 
1b5eb4d
d22a000
2ec1597
 
 
d22a000
 
 
7b125af
ac434a0
1b5eb4d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b125af
1b5eb4d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
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
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

import json
import datasets
from datasets.utils.file_utils import xopen

class SSL4EOEUForest(datasets.GeneratorBasedBuilder):
    """

    Metadata generator for the SSL4EO-EU-Forest dataset, cf. https://huggingface.co/datasets/dm4eo/ssl4eo_eu_forest .

    """
    def _info(self):
        """

        Provides details on metadata structure, citation, and credits.

        """
        return datasets.DatasetInfo(
            description="SSL4EO-EU Forest dataset metadata",
            features=datasets.Features({
                # data sample ID
                "group_id": datasets.Value("string"),
                # relative path (without HuggingFace URL) of forest mask
                "mask_path": datasets.Value("string"),
                # got bounding box in lat-lon coords
                "bbox_epsg4326": datasets.Sequence(datasets.Value("float32")),
                # image dimensions in width and height
                "mask_width": datasets.Value("int32"),
                "mask_height": datasets.Value("int32"),
                # do the above dimensions match for all the images?
                "dimensions_match": datasets.Value("bool"),
                # 12-band Sentinel-2 L2A cloud-free images for all seasons in bounding box 
                "images": datasets.Sequence({
                    # relative path (without HuggingFace URL) of Sentinel-2 imagery
                    "path": datasets.Value("string"),
                    # start time for data recording
                    "timestamp_start": datasets.Value("string"),
                    # end time for data recording
                    "timestamp_end": datasets.Value("string"),
                    # Sentinel-2 tile ID
                    "tile_id": datasets.Value("string"),
                    # season in northern hemisphere
                    "season": datasets.Value("string"),
                    # image dimensions
                    "width": datasets.Value("int32"),
                    "height": datasets.Value("int32")
                })
            }),
            # which keys refer to (input, output) data for supervised
            supervised_keys=("images", "mask_path"),
            # BibTeX on how to cite this work
            citation="""@misc{ssl4eo_eu_forest,

author = {Nassim Ait Ali Braham and Conrad M Albrecht},

title = {SSL4EO-EU Forest Dataset},

year = {2025},

howpublished = {https://huggingface.co/datasets/dm4eo/ssl4eo-eu-forest},

note = {This work was carried under the EvoLand project, cf. https://www.evo-land.eu . This project has received funding from the European Union's Horizon Europe research and innovation programme under grant agreement No. 101082130.}

}""",
            # project homepage
            homepage="https://www.evo-land.eu",
            # data license
            license="CC-BY-4.0",
        )

    def _split_generators(self, dl_manager):
        """

        Define dataset splits - single "training" split for now.

        """
        url = f"{dl_manager._base_path}/meta.jsonl"
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={"url": url},
            )
        ]

    def _generate_examples(self, url):
        """

        Streaming-compliant serving of metadata for SSL4EO data samples.

        """
        with xopen(url, encoding="utf-8") as f:
            for idx, line in enumerate(f):
                yield idx, json.loads(line)


def features_to_croissant(features):
    """

    Convert a HF dataset feature into a Croissant-compatible description.

    """
    def convert_feature(name:str, feature:datasets.features.features.Features):
        if isinstance(feature, datasets.Value):
            return {
                "name": name,
                "dataType": feature.dtype,
                "description": f"{name} field"
            }
        elif isinstance(feature, datasets.Sequence):
            inner = feature.feature
            if isinstance(inner, dict):  # nested structure
                return {
                    "name": name,
                    "isArray": True,
                    "description": f"{name} sequence",
                    "features": [convert_feature(k, v) for k, v in inner.items()]
                }
            elif isinstance(inner, Value):  # flat sequence
                return {
                    "name": name,
                    "isArray": True,
                    "description": f"{name} sequence",
                    "dataType": inner.dtype
                }
        else:
            return {
                "name": name,
                "dataType": "unknown",
                "description": f"{name} field"
            }

    return [convert_feature(name, feature) for name, feature in features.items()]