Skip to content

Commit 14e87fd

Browse files
philvarnerjsignell
andauthored
Updates and fixes to README, index, quickstart, and usage (#792)
* Updates and fixes to README, index, quickstart, and usage * remove incorrect link in pr template * Update docs/index.rst Co-authored-by: Julia Signell <[email protected]> * revert install instructions * User ORNL CLOUD for collections search * revert usage --------- Co-authored-by: Julia Signell <[email protected]>
1 parent 7cb5fd2 commit 14e87fd

File tree

5 files changed

+42
-33
lines changed

5 files changed

+42
-33
lines changed

.github/pull_request_template.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
- [ ] Code is formatted
1212
- [ ] Tests pass
13-
- [ ] Changes are added to the [CHANGELOG](https://github.com/stac-utils/pystac-api-client/blob/main/CHANGELOG.md)
13+
- [ ] Changes are added to CHANGELOG.md

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ 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+
To install with pip, run:
1519

1620
```shell
1721
python -m pip install pystac-client

docs/index.rst

+10-15
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 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,15 @@ STAC Versions
3730
Installation
3831
------------
3932

40-
.. code-block:: console
33+
``pystac-client`` requires `Python >=3.10 <https://www.python.org/>`__.
4134

42-
$ pip install pystac-client
35+
To install with pip, run:
36+
37+
.. code-block:: console
4338
44-
``pystac_client`` requires `Python >=3.8 <https://www.python.org/>`__.
39+
$ python -m pip install pystac-client
4540
46-
This will install the dependencies :doc:`PySTAC <pystac:index>`,
41+
This will install the dependencies :doc:`pystac <pystac:index>`,
4742
:doc:`python-dateutil <dateutil:index>`, and :doc:`requests <requests:index>`.
4843

4944
Acknowledgements

docs/quickstart.rst

+25-14
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,49 +120,60 @@ 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. Earth Search does not, so we use the
170+
ORNL_CLOUD CMR-STAC Catalog instead:
161171

162172
.. code-block:: python
163173
174+
client = Client.open("https://cmr.earthdata.nasa.gov/stac/ORNL_CLOUD")
164175
collection_search = client.collection_search(
165-
q='"sentinel-2" OR "sentinel-1"',
176+
q="rain",
166177
)
167178
print(f"{collection_search.matched()} collections found")
168179

pystac_client/collection_search.py

-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ def matched(self) -> int | None:
372372
count = len(page["collections"])
373373

374374
for page in iter:
375-
print(f"found {len(page['collections'])} on the next page")
376375
count += len(page["collections"])
377376

378377
found = count

0 commit comments

Comments
 (0)