Open-EO / openeo-geopyspark-driver

OpenEO driver for GeoPySpark (Geotrellis)
Apache License 2.0
26 stars 4 forks source link

raster_to_vector produces a geojson file with the wrong crs #886

Open JeroenVerstraelen opened 1 day ago

JeroenVerstraelen commented 1 day ago

Example:

import openeo
from openeo.rest.datacube import DataCube
from openeo.rest.datacube import UDF

connection = openeo.connect("openeo-dev.vito.be").authenticate_oidc()
bbox = [5.0, 51.2, 5.1, 51.3]
temp_ext = ["2023-01-01", "2023-01-20"]

s2_bands = connection.load_collection(
    "SENTINEL2_L2A", spatial_extent=dict(zip(["west", "south", "east", "north"], bbox)), temporal_extent=temp_ext, bands=["SCL"]
)

scl_band = s2_bands.band("SCL")
s2_cloudmask = ( (scl_band == 1) ) * 1.0

vector = s2_cloudmask.raster_to_vector()
vector.download("s2_cloudmask.geojson", format="geojson")

Output:

{
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "2023-01-02T00:00:00Z~band0": null, "2023-01-05T00:00:00Z~band0": null, "2023-01-07T00:00:00Z~band0": null, "2023-01-10T00:00:00Z~band0": null, "2023-01-15T00:00:00Z~band0": 0.0, "2023-01-17T00:00:00Z~band0": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 639420.0, 5685300.0 ], [ 639420.0, 5673960.0 ], [ 646720.0, 5673960.0 ], [ 646720.0, 5685300.0 ], [ 639420.0, 5685300.0 ] ] ] } },
{ "type": "Feature", "properties": { "2023-01-02T00:00:00Z~band0": null, "2023-01-05T00:00:00Z~band0": 0.0, "2023-01-07T00:00:00Z~band0": null, "2023-01-10T00:00:00Z~band0": null, "2023-01-15T00:00:00Z~band0": null, "2023-01-17T00:00:00Z~band0": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 639420.0, 5685300.0 ], [ 639420.0, 5673960.0 ], [ 646720.0, 5673960.0 ], [ 646720.0, 5685300.0 ], [ 639420.0, 5685300.0 ] ] ] } },
{ "type": "Feature", "properties": { "2023-01-02T00:00:00Z~band0": null, "2023-01-05T00:00:00Z~band0": null, "2023-01-07T00:00:00Z~band0": null, "2023-01-10T00:00:00Z~band0": null, "2023-01-15T00:00:00Z~band0": null, "2023-01-17T00:00:00Z~band0": 0.0 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 639420.0, 5685300.0 ], [ 639420.0, 5673960.0 ], [ 646720.0, 5673960.0 ], [ 646720.0, 5685300.0 ], [ 639420.0, 5685300.0 ] ] ] } },
{ "type": "Feature", "properties": { "2023-01-02T00:00:00Z~band0": 0.0, "2023-01-05T00:00:00Z~band0": null, "2023-01-07T00:00:00Z~band0": null, "2023-01-10T00:00:00Z~band0": null, "2023-01-15T00:00:00Z~band0": null, "2023-01-17T00:00:00Z~band0": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 639420.0, 5685300.0 ], [ 639420.0, 5673960.0 ], [ 646720.0, 5673960.0 ], [ 646720.0, 5685300.0 ], [ 639420.0, 5685300.0 ] ] ] } },
{ "type": "Feature", "properties": { "2023-01-02T00:00:00Z~band0": null, "2023-01-05T00:00:00Z~band0": null, "2023-01-07T00:00:00Z~band0": null, "2023-01-10T00:00:00Z~band0": 0.0, "2023-01-15T00:00:00Z~band0": null, "2023-01-17T00:00:00Z~band0": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 639420.0, 5685300.0 ], [ 639420.0, 5673960.0 ], [ 646720.0, 5673960.0 ], [ 646720.0, 5685300.0 ], [ 639420.0, 5685300.0 ] ] ] } },
{ "type": "Feature", "properties": { "2023-01-02T00:00:00Z~band0": null, "2023-01-05T00:00:00Z~band0": null, "2023-01-07T00:00:00Z~band0": 0.0, "2023-01-10T00:00:00Z~band0": null, "2023-01-15T00:00:00Z~band0": null, "2023-01-17T00:00:00Z~band0": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 639420.0, 5685300.0 ], [ 639420.0, 5673960.0 ], [ 646720.0, 5673960.0 ], [ 646720.0, 5685300.0 ], [ 639420.0, 5685300.0 ] ] ] } }
]
}

The features are in 32632 projection, but the FeatureCollection has CRS84 as crs.