Skip to content

Commit 37281b9

Browse files
committed
Updates and fixes to README, index, quickstart, and usage
1 parent 7cb5fd2 commit 37281b9

File tree

4 files changed

+73
-36
lines changed

4 files changed

+73
-36
lines changed

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,27 @@ A Python client for working with [STAC](https://stacspec.org/) APIs.
1010

1111
## Installation
1212

13-
Install from PyPi.
14-
Other than [PySTAC](https://pystac.readthedocs.io) itself, the only dependencies for **pystac-client** are the Python [requests](https://docs.python-requests.org) and [dateutil](https://dateutil.readthedocs.io) libraries.
13+
PySTAC Client is published to PyPi as [pystac-client](https://pypi.org/project/pystac-client/).
14+
15+
The only direct Python dependencies of **pystac-client** are [PySTAC](https://pystac.readthedocs.io),
16+
[requests](https://docs.python-requests.org), and [dateutil](https://dateutil.readthedocs.io).
17+
18+
pip:
19+
20+
```shell
21+
pip install pystac-client
22+
```
23+
24+
uv:
25+
26+
```shell
27+
uv add pystac-client
28+
```
29+
30+
poetry:
1531

1632
```shell
17-
python -m pip install pystac-client
33+
poetry add pystac-client
1834
```
1935

2036
## Documentation

docs/index.rst

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
.. pystac-client documentation master file, created by
2-
sphinx-quickstart on Sat Feb 27 14:27:12 2021.
3-
You can adapt this file completely to your liking, but it should at least
4-
contain the root `toctree` directive.
5-
61
PySTAC Client Documentation
72
===========================
83

9-
The STAC Python Client (``pystac_client``) is a Python package for working with STAC
10-
Catalogs and APIs that conform to the
11-
`STAC <https://github.com/radiantearth/stac-spec>`__ and
12-
`STAC API <https://github.com/radiantearth/stac-api-spec>`__ specs in a seamless way.
4+
PySTAC Client is a is a Python package for working with `STAC <https://github.com/radiantearth/stac-spec>`__
5+
Catalogs and `STAC APIs <https://github.com/radiantearth/stac-api-spec>`__.
136
PySTAC Client builds upon PySTAC through higher-level functionality and ability to
14-
leverage STAC API search endpoints.
7+
access STAC API search endpoints.
158

169
STAC Versions
1710
=============
@@ -20,7 +13,7 @@ STAC Versions
2013
| pystac-client | STAC spec | STAC API Spec |
2114
+===============+===========+=============================+
2215
| 0.8.x | 1.0.x | 1.0.0-beta.1 - 1.0.0 |
23-
+ --------------+-----------+-----------------------------+
16+
+---------------+-----------+-----------------------------+
2417
| 0.7.x | 1.0.x | 1.0.0-beta.1 - 1.0.0 |
2518
+---------------+-----------+-----------------------------+
2619
| 0.6.x | 1.0.x | 1.0.0-beta.1 - 1.0.0-rc.2 |
@@ -37,13 +30,28 @@ STAC Versions
3730
Installation
3831
------------
3932

33+
``pystac-client`` requires `Python >=3.10 <https://www.python.org/>`__.
34+
35+
pip:
36+
4037
.. code-block:: console
4138
4239
$ pip install pystac-client
4340
44-
``pystac_client`` requires `Python >=3.8 <https://www.python.org/>`__.
41+
uv:
42+
43+
.. code-block:: console
44+
45+
$ uv add pystac-client
46+
47+
poetry:
48+
49+
.. code-block:: console
50+
51+
$ poetry add pystac-client
52+
4553
46-
This will install the dependencies :doc:`PySTAC <pystac:index>`,
54+
This will install the dependencies :doc:`pystac <pystac:index>`,
4755
:doc:`python-dateutil <dateutil:index>`, and :doc:`requests <requests:index>`.
4856

4957
Acknowledgements

docs/quickstart.rst

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Quickstart
22
----------
33

4-
pystac-client can be used as either a Command Line Interface (CLI) or a
4+
PySTAC Client can be used as either a Command Line Interface (CLI) or a
55
Python library.
66

77
CLI
88
~~~
99

10-
Use the CLI to quickly make item- or collection-level searches and
10+
Use the CLI to quickly perform Item or Collection searches and
1111
output or save the results.
1212

1313
The ``--matched`` switch performs a search with limit=1 so does not get
@@ -108,7 +108,7 @@ a spatial extent that intersects Scandinavia.
108108
43 items matched
109109
110110
Since most STAC APIs have not yet implemented the `collection search
111-
extension <https://github.com/stac-api-extensions/collection-search>`_,
111+
extension <https://github.com/stac-api-extensions/collection-search>`__,
112112
``pystac-client`` will perform a limited client-side
113113
filter on the full list of collections using only the ``bbox``,
114114
``datetime``, and ``q`` (free-text search) parameters.
@@ -120,50 +120,62 @@ applied client-side.
120120
Python
121121
~~~~~~
122122

123-
To use the Python library, first a Client instance is created for a
124-
specific STAC API (use the root URL):
123+
First, create a Client instance configured to use a specific STAC API by the root URL of that API. For this example, we
124+
will use `Earth Search <https://earth-search.aws.element84.com/v1>`__.
125125

126126
.. code-block:: python
127127
128128
from pystac_client import Client
129129
130130
client = Client.open("https://earth-search.aws.element84.com/v1")
131131
132-
Create an item-level search:
132+
Create an Item Search instance that represents a search to run. This does not actually run a search yet --
133+
that does not happen until a method is called that requires data from the STAC API.
133134

134135
.. code-block:: python
135136
136137
search = client.search(
137138
max_items=10,
138-
collections=['sentinel-2-l2a'],
139+
collections=["sentinel-2-c1-l2a"],
139140
bbox=[-72.5,40.5,-72,41]
140141
)
142+
143+
Calling ``matched()`` will send a request to the STAC API and retrieve a single item and metadata about how many Items
144+
match the search criteria.
145+
146+
.. code-block:: python
147+
141148
print(f"{search.matched()} items found")
142149
143-
The ``items()`` iterator method can be used to iterate through all resulting items.
150+
The ``items()`` iterator method can be used to iterate through all resulting items. This iterator
151+
hides the pagination behavior that the may occur if there are sufficient results. Be careful with this
152+
method -- you could end up iterating over the entire catalog if ``max_items`` is not set!
144153

145154
.. code-block:: python
146155
147156
for item in search.items():
148157
print(item.id)
149158
150-
Use `item_collection()` to convert all Items from a search into a single `PySTAC
159+
Use ``item_collection()`` to convert all Items from a search into a single `PySTAC
151160
ItemCollection <https://pystac.readthedocs.io/en/latest/api/pystac.html#pystac.ItemCollection>`__.
152-
The ``ItemCollection`` can then be saved as a GeoJSON FeatureCollection.
161+
The ``ItemCollection`` can then be saved as a GeoJSON FeatureCollection. This requires retrieving all
162+
of the results from the search, so it may take some time to retrieve all the paginated responses.
153163

154164
.. code-block:: python
155165
156166
item_collection = search.item_collection()
157-
item_collection.save_object('my_itemcollection.json')
158-
167+
item_collection.save_object("my_itemcollection.json")
159168
160-
Create a collection-level search:
169+
Some STAC APIs also implement the Collection Search Extension.
161170

162171
.. code-block:: python
163172
173+
client = Client.open("https://emc.spacebel.be")
174+
164175
collection_search = client.collection_search(
165-
q='"sentinel-2" OR "sentinel-1"',
176+
q='Sentinel-6',
166177
)
178+
167179
print(f"{collection_search.matched()} collections found")
168180
169181
@@ -172,6 +184,6 @@ resulting collections.
172184

173185
.. code-block:: python
174186
175-
for collection in collection_search.collections():
176-
print(collection.id)
187+
for collection in collection_search.collections_as_dicts():
188+
print(collection.get("id"))
177189

docs/usage.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ optional specifications:
9595

9696
The :meth:`pystac_client.Client.conforms_to` method is used to check conformance
9797
against conformance classes (specs). To check an API for support for a given spec,
98-
pass the `conforms_to` function the name of a :class:`ConformanceClasses`.
98+
pass the `conforms_to` function a :class:`ConformanceClasses` enum value.
9999

100100
.. code-block:: python
101101
102-
>>> catalog.conforms_to("ITEM_SEARCH")
102+
>>> from pystac_client import ConformanceClasses
103+
>>> catalog.conforms_to(ConformanceClasses.ITEM_SEARCH)
103104
True
104105
105106
If the API does not advertise conformance with a particular spec, but it does support
@@ -110,9 +111,9 @@ there are no ``"conformsTo"`` uris set at all. But they can be explicitly set:
110111
111112
>>> catalog = Client.open("https://earth-search.aws.element84.com/v0")
112113
<stdin>:1: NoConformsTo: Server does not advertise any conformance classes.
113-
>>> catalog.conforms_to("ITEM_SEARCH")
114+
>>> catalog.conforms_to(ConformanceClasses.ITEM_SEARCH)
114115
False
115-
>>> catalog.add_conforms_to("ITEM_SEARCH")
116+
>>> catalog.add_conforms_to(ConformanceClasses.ITEM_SEARCH)
116117
117118
Note, updating ``"conformsTo"`` does not change what the server supports, it just
118119
changes PySTAC client's understanding of what the server supports.

0 commit comments

Comments
 (0)