-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Would it make sense to add support for loading Collection
, Item
, and ItemCollection
objects from pystac
? It could be useful in python workflows that generate STAC metadata and load directly into pgstac
.
Right now, I do something like this:
import io
import json
from pypgstac.db import PgstacDB
from pypgstac.load import Loader, Methods
from pystac import ItemCollection
from stactools.package import create_item
# fire up pgstac loader
db = PgstacDB()
loader = Loader(db=db)
# create item collection
item_collection = ItemCollection(
create_item(href) for href in hrefs
)
# write to ndjson and load into pgstac
buffer = io.BytesIO()
for item in item_collection:
item.collection_id = COLLECTION_ID_FORMAT.format(
region=region.value, product=product.value
)
buffer.write((json.dumps(item.to_dict()) + "\n").encode("utf-8"))
buffer.seek(0)
loader.load_items(buffer, insert_mode=Methods.upsert)
It isn't that hard to write to ndjson and pass that to load_items
, but it would be nice if that operation was handled by pypgstac
!
zacdezgeo
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request