|
28 | 28 |
|
29 | 29 | DOWNLOAD_DIR = os.getenv('TEST_DOWNLOAD_DIR', '.')
|
30 | 30 |
|
| 31 | +# The Orders API will be asked to mask, or clip, results to |
| 32 | +# this area of interest. |
31 | 33 | iowa_aoi = {
|
32 | 34 | "type":
|
33 | 35 | "Polygon",
|
|
36 | 38 | [-91.198465, 42.893071]]]
|
37 | 39 | }
|
38 | 40 |
|
39 |
| -iowa_images = ['20200925_161029_69_2223', '20200925_161027_48_2223'] |
| 41 | +# In practice, you will use a Data API search to find items, but |
| 42 | +# for this example take them as given. |
| 43 | +iowa_items = ['20200925_161029_69_2223', '20200925_161027_48_2223'] |
| 44 | + |
40 | 45 | iowa_order = planet.order_request.build_request(
|
41 |
| - 'iowa_order', |
42 |
| - [planet.order_request.product(iowa_images, 'analytic_udm2', 'PSScene')], |
43 |
| - tools=[planet.order_request.clip_tool(iowa_aoi)]) |
| 46 | + name='iowa_order', |
| 47 | + products=[ |
| 48 | + planet.order_request.product(item_ids=iowa_items, |
| 49 | + product_bundle='analytic_udm2', |
| 50 | + item_type='PSScene') |
| 51 | + ], |
| 52 | + tools=[planet.order_request.clip_tool(aoi=iowa_aoi)]) |
44 | 53 |
|
45 | 54 | oregon_aoi = {
|
46 | 55 | "type":
|
|
50 | 59 | [-117.558734, 45.229745]]]
|
51 | 60 | }
|
52 | 61 |
|
53 |
| -oregon_images = ['20200909_182525_1014', '20200909_182524_1014'] |
| 62 | +oregon_items = ['20200909_182525_1014', '20200909_182524_1014'] |
| 63 | + |
54 | 64 | oregon_order = planet.order_request.build_request(
|
55 |
| - 'oregon_order', |
56 |
| - [planet.order_request.product(oregon_images, 'analytic_udm2', 'PSScene')], |
57 |
| - tools=[planet.order_request.clip_tool(oregon_aoi)]) |
| 65 | + name='oregon_order', |
| 66 | + products=[ |
| 67 | + planet.order_request.product(item_ids=oregon_items, |
| 68 | + product_bundle='analytic_udm2', |
| 69 | + item_type='PSScene') |
| 70 | + ], |
| 71 | + tools=[planet.order_request.clip_tool(aoi=oregon_aoi)]) |
58 | 72 |
|
59 | 73 |
|
60 |
| -async def create_and_download(order_detail, directory, client): |
| 74 | +async def create_and_download(client, order_detail, directory): |
| 75 | + """Make an order, wait for completion, download files as a single task.""" |
61 | 76 | with planet.reporting.StateBar(state='creating') as reporter:
|
62 |
| - # create |
63 | 77 | order = await client.create_order(order_detail)
|
64 | 78 | reporter.update(state='created', order_id=order['id'])
|
65 |
| - |
66 |
| - # wait for completion |
67 | 79 | await client.wait(order['id'], callback=reporter.update_state)
|
68 | 80 |
|
69 |
| - # download |
70 | 81 | await client.download_order(order['id'], directory, progress_bar=True)
|
71 | 82 |
|
72 | 83 |
|
73 | 84 | async def main():
|
74 |
| - async with planet.Session() as ps: |
75 |
| - client = planet.OrdersClient(ps) |
76 |
| - |
| 85 | + async with planet.Session() as sess: |
| 86 | + client = sess.client('orders') |
77 | 87 | await asyncio.gather(
|
78 |
| - create_and_download(iowa_order, DOWNLOAD_DIR, client), |
79 |
| - create_and_download(oregon_order, DOWNLOAD_DIR, client), |
| 88 | + create_and_download(client, iowa_order, DOWNLOAD_DIR), |
| 89 | + create_and_download(client, oregon_order, DOWNLOAD_DIR), |
80 | 90 | )
|
81 | 91 |
|
82 | 92 |
|
|
0 commit comments