Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Notes on STAC Collection temporal extent and datetime summaries #186

Open
anayeaye opened this issue Jun 7, 2023 · 1 comment
Open

Comments

@anayeaye
Copy link
Collaborator

anayeaye commented Jun 7, 2023

What

This WIP tracks how to update the temporal extent and collection summaries for collections of items that use start/end datetimes. This provides guidance for manually updating collections and includes some notes about what is currently automated across the board--some implementations may already correct this, but here are methods for manually fixing a single collection.

Currently the functions built in to the veda-stac-ingestor might use the nominal datetime instant which does not capture items that represent a date range. The latest pgstac versions will update collection extents when a trigger is enabled but we need to confirm that the full datetime range is included.

Collection Temporal Extent

For now, a function that generates the temporal extent using the max end_datetime

-- make a re-usable function for the collection max temporal extent
CREATE OR REPLACE FUNCTION pgstac.collection_max_temporal_extent(id text)
 RETURNS jsonb
 LANGUAGE sql
 IMMUTABLE PARALLEL SAFE
 SET search_path TO 'pgstac', 'public'
 SET timezone to 'UTC'
AS $function$
    SELECT to_jsonb(
	            array[array[
			        to_char(min(items.datetime) at time zone 'Z', 'YYYY-MM-DD"T"HH24:MI:SS"Z"'),
            			to_char(max(items.end_datetime) at time zone 'Z', 'YYYY-MM-DD"T"HH24:MI:SS"Z"')
		            ]]
	            )
    FROM items WHERE collection=$1;;
$function$;

Now the above function can be used to set a collections temporal extent

-- update collection extents
SET timezone to 'UTC';
UPDATE collections SET
    "content" = "content" ||
    jsonb_build_object(
        'extent', jsonb_build_object(
            'spatial', jsonb_build_object(
                'bbox', collection_bbox(collections.id)
            ),
            'temporal', jsonb_build_object(
	            'interval', collection_max_temporal_extent(collections.id)
        	)	
    	)
   )
WHERE collections.id=:_collection_id;

Collection datetime summaries

We have already corrected the collection summaries here.
This function will eventually be updated to remove the cog_default raster logic, but today it works as designed for datetimes.

For dashboard:is_periodic collections the method is currently designed to return the full range of dates covered by the collection. For non-periodic collections every distinct nominal datetime instant will be returned. The purpose is to provide the minimum amount of information needed for a time selector in a dashboard explore view.

Update the summaries for a single collection

SELECT update_collection_default_summaries(collections.id)
FROM collections
WHERE collections.id = :_collection_id;
@anayeaye
Copy link
Collaborator Author

#344

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

No branches or pull requests

1 participant