-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeospatial.py
More file actions
48 lines (44 loc) · 1.6 KB
/
Copy pathgeospatial.py
File metadata and controls
48 lines (44 loc) · 1.6 KB
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
from datetime import datetime, timezone
import taco
contract = taco.Contract(
structure=["image.bin"],
metadata=taco.MetadataSchema(
taco.Level(
"sample",
stac=taco.extensions.STAC(),
majortom=taco.extensions.MajorTOM(
dist_km=100,
latitude_range=(-20, 0),
longitude_range=(-90, -60),
),
),
),
)
collection = taco.Collection(
contract=contract,
id="peru-sites",
dataset_version="1.0.0",
description="Small geospatial dataset with derived MajorTOM cells",
licenses=["MIT"],
providers=["Asterisk Labs"],
tasks=["classification"],
)
sites = [(-77.04, -12.05), (-71.97, -13.53), (-80.63, -5.19)]
with taco.open_writer(collection, "geospatial.zip", overwrite=True) as writer:
for index, (longitude, latitude) in enumerate(sites):
stac = taco.metadata.sample.STAC(
crs="EPSG:4326",
tensor_shape=(1, 8, 8),
geotransform=(longitude - 0.05, 0.0125, 0, latitude + 0.05, 0, -0.0125),
time_start=datetime(2024, 1, index + 1, tzinfo=timezone.utc),
)
asset = taco.Asset(bytes([index + 1]) * 64, path="image.bin")
writer.add(taco.Sample(assets=asset, metadata=taco.Metadata(stac=stac)))
writer.run()
dataset = taco.open_dataset("geospatial.zip")
table = taco.read(dataset)
assert table.num_rows == 3
assert "majortom:code" in table.column_names
assert dataset.collection.extent is not None
assert dataset.collection.extent.spatial == (-80.63, -13.53, -71.97, -5.19)
assert taco.validate("geospatial.zip").ok