ZGIS / semantique

Semantic Querying in Earth Observation Data Cubes
https://zgis.github.io/semantique/
Apache License 2.0
16 stars 6 forks source link

fix: Properties merge in collections :wrench: #39

Closed fkroeber closed 5 months ago

fkroeber commented 7 months ago

Description

This fix loads the reducer for the collection creation correctly. In is necessary when entities are defined by several properties that should be evaluated jointly. The changed behaviour with/without fix can be evaluated using the MRE below.

Minimum Reproducible Example (MRE)

import geopandas as gpd
import json
import semantique as sq
from semantique.processor.utils import parse_extent

# define mapping
# note: the texture attribute isn't meaningful but sufficient for demonstration purposes
mapping = sq.mapping.Semantique()
mapping["entity"] = {}
mapping["entity"]["water"] = {
    "color": sq.appearance("colortype").evaluate("in", [21, 22, 23, 24]),
    "texture": sq.appearance("greenness").evaluate("less", 2)
    }

# define extent
space = sq.SpatialExtent(gpd.read_file("files/footprint.geojson"))
time = sq.TemporalExtent("2019-01-01", "2020-12-31")
extent = parse_extent(space, time, spatial_resolution = [-10, 10], crs = 3035)

# define data cube
with open("files/layout.json", "r") as file:
    dc = sq.datacube.GeotiffArchive(json.load(file), src = "files/layers.zip")

# resolve semantic reference
water = mapping.translate("entity", "water", extent = extent, datacube = dc)

# plot result
levels = [-0.5, 0.5, 1.5]
legend = {"ticks": [0, 1], "label": "is_water"}
colors = ["lightgrey", "deepskyblue"]
water.plot(x = "x", y = "y", col = "time", colors = colors, levels = levels, cbar_kwargs = legend)

Type of change

Select one or more relevant options:

Checklist: