Skip to content

Commit 1e58f02

Browse files
Merge pull request #1166 from planetlabs/main
Update subscriptions clip tool docstrings (#1161)
2 parents a527c05 + 10f08ed commit 1e58f02

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

docs/python/sdk-guide.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ You will need your ACCESS_KEY_ID, SECRET_ACCESS_KEY, bucket and region name.
225225
To subscribe to scenes that match a filter, use the `subscription_request` module to build a request, and
226226
pass it to the `subscriptions.create_subscription()` method of the client.
227227

228+
By default, a request to create a subscription will not clip matching imagery which intersects the source geometry. To clip to the subscription source geometry, set `planet.subscription_request.build_request()` keyword argument `clip_to_source = True` as in the example below. To clip to a custom geometry, set `planet.subscription_request.build_request()` keyword argument `clip_to_source = False` (or omit it entirely to fall back on the default value), and instead configure the custom clip AOI with `planet.subscription_request.clip_tool()`.
229+
228230
Warning: the following code will create a subscription, consuming quota based on your plan.
229231

230232
```python
@@ -250,11 +252,12 @@ source = catalog_source(
250252
time_range_type="acquired",
251253
)
252254

253-
request = build_request("Standard PSScene Ortho Analytic", source=source, delivery={})
254-
255255
# define a delivery method. In this example, we're using AWS S3.
256256
delivery = amazon_s3(ACCESS_KEY_ID, SECRET_ACCESS_KEY, "test", "us-east-1")
257257

258+
# build the request payload
259+
request = build_request("Standard PSScene Ortho Analytic", source=source, delivery=delivery, clip_to_source=True)
260+
258261
# finally, create the subscription
259262
subscription = pl.subscriptions.create_subscription(request)
260263
```

planet/subscription_request.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,11 @@ def build_request(name: str,
7171
hosting: A hosting destination e.g. Sentinel Hub.
7272
collection_id: A Sentinel Hub collection ID.
7373
create_configuration: Automatically create a layer configuration for your collection.
74-
clip_to_source: whether to clip to the source geometry or not
75-
(the default). If True a clip configuration will be added to
76-
the list of requested tools unless an existing clip tool
77-
exists. NOTE: Not all data layers support clipping, please
78-
consult the Product reference before using this option.
79-
NOTE: the next version of the Subscription API will remove
80-
the clip tool option and always clip to the source geometry.
81-
Thus this is a preview of the next API version's default
82-
behavior.
74+
clip_to_source: Whether or not to clip to the source geometry (defaults to False). If
75+
True, a clip configuration that specifies the subscription source geometry as clip
76+
AOI will be added to the list of requested tools. If True and 'clip_tool()' is
77+
also specified, an exception will be raised. If False, no clip configuration
78+
will be added to the list of requested tools unless 'clip_tool()' is specified.
8379
8480
Returns:
8581
dict: a representation of a Subscriptions API request for
@@ -133,10 +129,7 @@ def build_request(name: str,
133129

134130
# If clip_to_source is True a clip configuration will be added
135131
# to the list of requested tools unless an existing clip tool
136-
# exists. In that case an exception is raised. NOTE: the next
137-
# version of the Subscription API will remove the clip tool
138-
# option and always clip to the source geometry. Thus this is a
139-
# preview of the next API version's default behavior.
132+
# exists. In that case an exception is raised.
140133
if clip_to_source:
141134
if any(tool.get('type', None) == 'clip' for tool in tool_list):
142135
raise ClientError(
@@ -656,6 +649,10 @@ def clip_tool(aoi: Mapping) -> dict:
656649
the clip aoi is so large that full scenes may be delivered without any
657650
clipping, those files will not have “_clip” appended to their file name.
658651
652+
NOTE: To clip to the source geometry, set the 'clip_to_source' parameter
653+
of 'planet.subscription_request.build_request()' to True instead of using
654+
this tool.
655+
659656
Parameters:
660657
aoi: GeoJSON polygon or multipolygon defining the clip area, with up to
661658
500 vertices. The minimum geographic area of any polygon or
@@ -665,6 +662,7 @@ def clip_tool(aoi: Mapping) -> dict:
665662
planet.exceptions.ClientError: If aoi is not a valid polygon or
666663
multipolygon.
667664
"""
665+
668666
valid_types = ['Polygon', 'MultiPolygon', 'ref']
669667

670668
geom = geojson.as_geom_or_ref(dict(aoi))

0 commit comments

Comments
 (0)