Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions docs/examples/example_store.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# type: ignore
"""
# Using object storage

[obstore](https://github.com/developmentseed/obstore) is a new, powerful Python library for getting from and putting to object storage.
**rustac** can use anything that implements [obstore.store.ObjectStore][], and also provides its own zero-dependency version in **rustac.store**.
"""

# %%
# ## Using **rustac.store**.

import contextily
import pandas
import rustac
from rustac.store import HTTPStore
from geopandas import GeoDataFrame

store = HTTPStore("https://raw.githubusercontent.com/stac-utils/rustac-py/refs/heads/main/data")
items = await rustac.read("100-sentinel-2-items.parquet", store=store)
print(len(items["features"]))

data_frame = GeoDataFrame.from_features(items)
data_frame["datetime"] = pandas.to_datetime(data_frame["datetime"])
axis = data_frame.set_crs(epsg=4326).to_crs(epsg=3857).plot(alpha=0.5, edgecolor="k")
contextily.add_basemap(axis, source=contextily.providers.CartoDB.Positron)
axis.set_axis_off()


# %%
# There's a [whole set][rustac.store.ObjectStore] of provided object storage backends.
# See <https://developmentseed.org/obstore/latest/authentication/> for how you might configure authenticate with those backends.

# %%
# ## Using **obstore.store.ObjectStore**.
#
# If you're doing work with **obstore** directly, you can re-use the same `ObjectStore`.

from obstore.store import HTTPStore

store = HTTPStore("https://raw.githubusercontent.com/stac-utils/rustac-py/refs/heads/main/data")
items = await rustac.read("100-sentinel-2-items.parquet", store=store)

# Notice how there's a warning?
# That's because we have to copy the `ObjectStore` when we pass it in to **rustac**.
# This means it can be a bit more efficient to use `rustac.store` if you're only working with **rustac**.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ docs = [
"mkdocs-gallery>=0.10.4",
"mkdocs-material[imaging]>=9.5.45",
"mkdocstrings[python]>=0.27.0",
"obstore>=0.6.0",
"pystac-client>=0.8.5",
]

Expand Down
51 changes: 51 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.