Skip to content

S14Amazonas preview#372

Open
JanssenBrm wants to merge 16 commits intomainfrom
s14amazonas_preview
Open

S14Amazonas preview#372
JanssenBrm wants to merge 16 commits intomainfrom
s14amazonas_preview

Conversation

@JanssenBrm
Copy link
Contributor

No description provided.

@JanssenBrm JanssenBrm changed the title S14amazonas preview S14Amazonas preview Feb 27, 2026
@JanssenBrm
Copy link
Contributor Author

Preview for #245

@algorithm-services-catalogue
Copy link

algorithm-services-catalogue bot commented Feb 27, 2026

🔍 Catalogue's Preview Site Deployed

Your changes have been deployed to the preview site:

🔗 Preview URL: https://esa-apex.github.io/apex-algorithms-catalogue-web/pr-preview/pr-372/

This preview will be updated automatically when you push new changes to your PR.

@sivasanarul
Copy link
Collaborator

I am trying to update the resto api inside the udf to Odata api. I am using this function which works offline when I call it like this
feats = fetch_s1_features(bbox_4326, temporal_dict["start"], temporal_dict["end"])
But it doesnt work when I use it inside udf:
Could you help me fix this:

temporal_dict = {
"start": pd.Timestamp("2020-01-17 00:00:00"),
"end": pd.Timestamp("2020-05-04 00:00:00"),
}
bbox_4326 = [-11.753685105, -55.165335994, -12.73714945, -54.158521354]
ODATA_URL = "https://datahub.creodias.eu/odata/v1/Products"
def fetch_s1_features(bbox: List[float], start_iso: str, end_iso: str) -> List[dict]:
"""
Query the Copernicus Dataspace OData API for Sentinel-1 features within bbox and datetime range.
Returns features in a format compatible with the rest of the code (OpenSearch-like structure).
"""
# bbox is [south, west, north, east] - convert to WKT polygon
south, west, north, east = bbox
polygon_wkt = f"POLYGON(({west} {south},{east} {south},{east} {north},{west} {north},{west} {south}))"

# Build OData filter parts
filters = [
    "Collection/Name eq 'SENTINEL-1'",
    f"ContentDate/Start gt {start_iso.strftime('%Y-%m-%dT00:00:00.000Z')}",
    f"ContentDate/Start lt {end_iso.strftime('%Y-%m-%dT23:59:59.999Z')}",
    f"OData.CSC.Intersects(area=geography'SRID=4326;{polygon_wkt}')",
    "Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productType' and att/OData.CSC.StringAttribute/Value eq 'IW_GRDH_1S-COG')",
]

filter_str = " and ".join(filters)

params = {
    "$filter": filter_str,
    "$top": 1000,
    "$expand": "Attributes",
    "$orderby": "ContentDate/Start asc",
}

r = requests.get(ODATA_URL, params=params, timeout=60)
r.raise_for_status()

odata_products = r.json().get("value", [])

# Transform OData response to OpenSearch-like format for compatibility
features = []
for prod in odata_products:
    # Extract orbitDirection from Attributes
    orbit_direction = "UNKNOWN"
    for attr in prod.get("Attributes", []):
        if attr.get("Name") == "orbitDirection":
            orbit_direction = attr.get("Value", "UNKNOWN")
            break
    
    # Build compatible feature structure
    feature = {
        "properties": {
            "title": prod.get("Name", ""),
            "orbitDirection": orbit_direction,
        },
        "geometry": prod.get("GeoFootprint", {}),
    }
    features.append(feature)
logger.info(f"-- fetched features {features} --")
return features

@JanssenBrm
Copy link
Contributor Author

@VictorVerhaert - Could you help with @sivasanarul question? @sivasanarul - maybe it is best to iterate on the GitHub repo where the actual code is located through a GitHub issue? Otherwise, we will have too many locations where discussions are tracked.

@sivasanarul
Copy link
Collaborator

@VictorVerhaert https://github.com/Gisat/dev-S14amazonas/blob/main/apex_integration_dev.py
https://github.com/Gisat/dev-S14amazonas/blob/main/udf_apex_S1backscatter_changedetection.py

These are the relevant scripts that is updated with the Odata api. You already make a pull request there.

this script is used to test only the fetch_s1_features function:
apex_udf_call.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants