2828
2929DOWNLOAD_DIR = os .getenv ('TEST_DOWNLOAD_DIR' , '.' )
3030
31- # The Orders API will be asked to mask, or clip, results to
32- # this area of interest.
33- iowa_aoi = {
34- "type" :
35- "Polygon" ,
36- "coordinates" : [[[- 91.198465 , 42.893071 ], [- 91.121931 , 42.893071 ],
37- [- 91.121931 , 42.946205 ], [- 91.198465 , 42.946205 ],
38- [- 91.198465 , 42.893071 ]]]
39- }
40-
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-
45- iowa_order = planet .order_request .build_request (
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 )])
53-
54- oregon_aoi = {
55- "type" :
56- "Polygon" ,
57- "coordinates" : [[[- 117.558734 , 45.229745 ], [- 117.452447 , 45.229745 ],
58- [- 117.452447 , 45.301865 ], [- 117.558734 , 45.301865 ],
59- [- 117.558734 , 45.229745 ]]]
60- }
61-
62- oregon_items = ['20200909_182525_1014' , '20200909_182524_1014' ]
63-
64- oregon_order = planet .order_request .build_request (
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 )])
31+
32+ def create_requests ():
33+ # The Orders API will be asked to mask, or clip, results to
34+ # this area of interest.
35+ iowa_aoi = {
36+ "type" :
37+ "Polygon" ,
38+ "coordinates" : [[[- 91.198465 , 42.893071 ], [- 91.121931 , 42.893071 ],
39+ [- 91.121931 , 42.946205 ], [- 91.198465 , 42.946205 ],
40+ [- 91.198465 , 42.893071 ]]]
41+ }
42+
43+ # In practice, you will use a Data API search to find items, but
44+ # for this example take them as given.
45+ iowa_items = ['20200925_161029_69_2223' , '20200925_161027_48_2223' ]
46+
47+ iowa_order = planet .order_request .build_request (
48+ name = 'iowa_order' ,
49+ products = [
50+ planet .order_request .product (item_ids = iowa_items ,
51+ product_bundle = 'analytic_udm2' ,
52+ item_type = 'PSScene' )
53+ ],
54+ tools = [planet .order_request .clip_tool (aoi = iowa_aoi )])
55+
56+ oregon_aoi = {
57+ "type" :
58+ "Polygon" ,
59+ "coordinates" : [[[- 117.558734 , 45.229745 ], [- 117.452447 , 45.229745 ],
60+ [- 117.452447 , 45.301865 ], [- 117.558734 , 45.301865 ],
61+ [- 117.558734 , 45.229745 ]]]
62+ }
63+
64+ oregon_items = ['20200909_182525_1014' , '20200909_182524_1014' ]
65+
66+ oregon_order = planet .order_request .build_request (
67+ name = 'oregon_order' ,
68+ products = [
69+ planet .order_request .product (item_ids = oregon_items ,
70+ product_bundle = 'analytic_udm2' ,
71+ item_type = 'PSScene' )
72+ ],
73+ tools = [planet .order_request .clip_tool (aoi = oregon_aoi )])
74+
75+ return [iowa_order , oregon_order ]
7276
7377
7478async def create_and_download (client , order_detail , directory ):
@@ -84,10 +88,13 @@ async def create_and_download(client, order_detail, directory):
8488async def main ():
8589 async with planet .Session () as sess :
8690 client = sess .client ('orders' )
87- await asyncio .gather (
88- create_and_download (client , iowa_order , DOWNLOAD_DIR ),
89- create_and_download (client , oregon_order , DOWNLOAD_DIR ),
90- )
91+
92+ requests = create_requests ()
93+
94+ await asyncio .gather (* [
95+ create_and_download (client , request , DOWNLOAD_DIR )
96+ for request in requests
97+ ])
9198
9299
93100if __name__ == '__main__' :
0 commit comments