Skip to content

Update polygon point coverage fails #11

@mosoriob

Description

@mosoriob

The dataset has one resource:

postgres=# select * from resources where dataset_id='5ca18d80-dd88-4f95-9e1c-665289756748';
-[ RECORD 1 ]-+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
data_url      | https://data.mint.isi.edu/files/cycles-input-data/africa/soil_weather/cycles-6.87500-37.87500.soil_weather.zip
resource_type | Zip
json_metadata | {"spatial_coverage": {"type": "Point", "value": {"x": 37.0, "y": 6.0}}, "temporal_coverage": {"end_time": "2021-03-30T00:00:00", "start_time": "2000-01-01T00:00:00"}}
layout        | {}
created_at    | 2023-06-09 15:33:12.448088
updated_at    | 2023-06-09 15:33:12.448088
name          | cycles-6.87500-37.87500.soil_weather.zip
id            | 202c581c-7e81-4933-afad-28ef1d320118
dataset_id    | 5ca18d80-dd88-4f95-9e1c-665289756748
provenance_id | 9ef60317-5da5-4050-8bbc-7d6826fee49f
is_queryable  | t

The sync_dataset_metadata triggers the function _update_polygon_point_coverage_ds. However, the query doesn't work

                with spatial_coverage as (
        	        select
        	            dataset_id,
        	            ST_union(ST_Simplify(st_buffer(spatial_coverage_index.spatial_coverage, 0.1), 0.1)) as dataset_spatial_coverage
        	        from resources
        	        inner join spatial_coverage_index on resources.id = spatial_coverage_index.indexed_id
        	        --and resources.is_queryable is TRUE
        	        where st_geometrytype(spatial_coverage_index.spatial_coverage) like '%Point'
                    and dataset_id='{dsid}'
        	        group by dataset_id
                )
                update datasets
                SET spatial_coverage = sc.dataset_spatial_coverage
                from spatial_coverage sc
                where sc.dataset_id = datasets.id"""

Inspecting the issue, the SELECT is returning an empty dataset_spatial_coverage value

       	        select
        	            dataset_id,
        	            ST_union(ST_Simplify(st_buffer(spatial_coverage_index.spatial_coverage, 0.1), 0.1)) as dataset_spatial_coverage
        	        from resources
        	        inner join spatial_coverage_index on resources.id = spatial_coverage_index.indexed_id
        	        --and resources.is_queryable is TRUE
        	        where st_geometrytype(spatial_coverage_index.spatial_coverage) like '%Point'
                    and dataset_id='5ca18d80-dd88-4f95-9e1c-665289756748'
        	        group by dataset_id

postgres-#                 group by dataset_id;
-[ RECORD 1 ]------------+-------------------------------------
dataset_id               | 5ca18d80-dd88-4f95-9e1c-665289756748
dataset_spatial_coverage | 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions