Open-EO / openeo-processes

Interoperable processes for openEO's big Earth observation cloud processing.
https://processes.openeo.org
Apache License 2.0
48 stars 15 forks source link

Cropping cumbersome #378

Closed m-mohr closed 1 year ago

m-mohr commented 2 years ago

Feedback from METER group is that cropping to a GeoJSON is cumbersome as you need to run two processes:

Might be a client improvement, but maybe we can also enforce implicit filtering in mask_polygon or implicit masking in filter_spatial? Not sure yet...

soxofaan commented 2 years ago

FYI: In VITO back-end we allow just specifying mask_polygon and automatically inferring the spatial extent for load_collection from that, e.g. see https://github.com/Open-EO/openeo-python-driver/commit/9548306e5392d4a2787f9fc4ffbf4dd0bf27ced1

m-mohr commented 1 year ago

I think there is no feasible solution right now:

I guess we can make a crop_polygon UDP available that combines these both processes.

ToDo:

{
    "id": "crop_polygon",
    "summary": "Crop using a polygon",
    "description": "Crops a datacube to the given polygons by filtering and masking. This process executes the two processes ``filter_spatial()`` and ``mask_polygon()`` consecutively.",
    "categories": [
        "cubes",
        "filter",
        "masks"
    ],
    "parameters": [
        {
            "name": "data",
            "description": "A raster data cube.",
            "schema": {
                "type": "object",
                "subtype": "raster-cube"
            }
        },
        {
            "name": "mask",
            "description": "A GeoJSON object containing at least one polygon. The provided feature types can be one of the following:\n\n* A `Polygon` or `MultiPolygon` geometry,\n* a `Feature` with a `Polygon` or `MultiPolygon` geometry or,\n* a `FeatureCollection` containing at least one `Feature` with `Polygon` or `MultiPolygon` geometries.",
            "schema": [
                {
                    "type": "object",
                    "subtype": "geojson"
                },
                {
                    "type": "object",
                    "subtype": "vector-cube"
                }
            ]
        },
        {
            "name": "replacement",
            "description": "The value used to replace masked values with.",
            "schema": [
                {
                    "type": "number"
                },
                {
                    "type": "boolean"
                },
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "default": null,
            "optional": true
        }
    ],
    "returns": {
        "description": "A masked data cube restricted to the specified geometries. The dimensions and dimension properties (name, type, labels, reference system and resolution) remain unchanged, except that the spatial dimensions have less (or the same) dimension labels.",
        "schema": {
            "type": "object",
            "subtype": "raster-cube"
        }
    },
    "links": [
        {
            "href": "http://www.opengeospatial.org/standards/sfa",
            "rel": "about",
            "title": "Simple Features standard by the OGC"
        }
    ],
    "process_graph": {
        "filter": {
            "process_id": "filter_spatial",
            "arguments": {
                "data": {
                    "from_parameter": "data"
                },
                "geometries": {
                    "from_parameter": "mask"
                }
            }
        },
        "mask": {
            "process_id": "mask_polygon",
            "arguments": {
                "data": {
                    "from_node": "filter"
                },
                "replacement": {
                    "from_parameter": "replacement"
                },
                "mask": {
                    "from_parameter": "mask"
                },
                "inside": false
            },
            "result": true
        }
    }
}
m-mohr commented 1 year ago

See https://github.com/Open-EO/openeo-community-examples/blob/main/processes/crop_polygon.json and https://github.com/Open-EO/openeo-community-examples/pull/5