You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
planet data filter --geom - | planet data stats PSScene --interval year --filter - | jq '.buckets | map(.count) | add'
407
+
```
408
+
409
+
Just pipe the results to `jq '.buckets | map(.count) | add'` and it'll give you the total of all the values.
410
+
411
+
## Asset Activation and Download
412
+
413
+
While we recommend using the Orders or Subscriptions API's to deliver Planet data, the Data API has the capability
414
+
to activate and download data. Only one asset can be activated at once, and there is no clipping or additional
415
+
processing of the data like the great 'tools' of Subscriptions & Orders. But the advantage is that it can often
416
+
be faster for working with a small number of items & assets.
417
+
418
+
### Activate an Asset
419
+
420
+
All items in the Data API have a list of assets. This includes the main imagery geotiff files, usually in a few
421
+
different formats, and also accompanying files like the [Usable Data Mask](https://developers.planet.com/docs/data/udm-2/)
422
+
(UDM) and JSON metadata. You can't immediately download them, as they must first be created in the cloud, known as
423
+
'activated'. To activate data you need to get its item id, plus the name of the asset - the available ones
424
+
can be seen by looking at the Item's JSON. Once you have the item id and asset type you can run the CLI
425
+
426
+
```
427
+
planet data asset-activate PSScene 20230310_083933_71_2431 ortho_udm2
428
+
```
429
+
430
+
This will kick off the activation process, and the command should return immediately. In this example
431
+
we're activating the UDM, which is one of the most common things to do through the Data API, to
432
+
first get a sense of where there are clouds before placing a proper clipping order.
433
+
434
+
### Download an Asset
435
+
436
+
Once an asset is ready you can use `asset-download` with a similar command:
437
+
438
+
```
439
+
planet data asset-download PSScene 20230310_083933_71_2431 ortho_udm2
440
+
```
441
+
442
+
While some assets activate almost immediately (if another user has requested
443
+
it recently), some can take a few minutes. If you try to download it before it's active
444
+
you'll get a message like: `Error: asset missing ["location"] entry. Is asset active?`
445
+
446
+
Thankfully the CLI has the great `asset-wait` command will complete when the asset is activated:
447
+
448
+
```
449
+
planet data asset-wait PSScene 20230310_083933_71_2431 ortho_udm2
450
+
```
451
+
452
+
And you can pair with download so that as soon as the asset is active it'll be downloaded:
453
+
454
+
```
455
+
planet data asset-wait PSScene 20230310_083933_71_2431 ortho_udm2 && \
456
+
planet data asset-download PSScene 20230310_083933_71_2431 ortho_udm2
457
+
```
458
+
459
+
Download has a few different options:
460
+
461
+
*`--directory` lets you specify a base directory to put the asset in.
462
+
*`--filename` assigns a custom name to the downloaded file.
463
+
*`--overwrite` will overwrite files if they already exist.
464
+
*`--checksum` checks to make sure the file you downloaded is the exact same as the one on the server. This can be useful if you script thousands of files to download to detect any corruptions in that process.
465
+
466
+
## Saved Searches
467
+
468
+
The core `planet data search` command uses what is called a 'quick search' in the API. The API
469
+
also supports what we call a '[saved searches](https://developers.planet.com/docs/apis/data/quick-saved-search/#saved-search)',
470
+
and the CLI supports this as well.
471
+
472
+
### List Searches
473
+
474
+
You can easily get a list of all the searches you've made:
475
+
476
+
```
477
+
planet data search-list
478
+
```
479
+
480
+
This defaults to returning 100 results, but you can use `--limit` to return the number you
481
+
specify, and set it to 0 to return all your searches. By default this returns both
482
+
your quick searches and saved searches, but you can also limit to to only return
483
+
your saved searches:
484
+
485
+
```
486
+
planet data search-list --search-type saved
487
+
```
488
+
489
+
If you've not created any saved searches it may be an empty list. You can create
490
+
saved searches with Planet Explorer, or it's also easy with the command-line.
491
+
492
+
### Create Search
493
+
494
+
To make a new saved search you can use the exact same filter syntax as the regular `search` command,
495
+
but you must also add a 'name' to refer to the search by:
496
+
497
+
```
498
+
planet data filter --geom geometry.geojson | planet data search-create PSScene --name 'my saved search' --filter -
499
+
```
500
+
501
+
### Run Search
502
+
503
+
When you save a new search you'll get back the JSON describing the search. If you grab the 'id' field from it then
504
+
you can get the current results for that search:
505
+
506
+
```
507
+
planet data search-run da963039dbe94573a3ac9e4629d065b6
508
+
```
509
+
510
+
This is just like running a normal (quick) search, and takes similar arguments: `--limit` and `--pretty`,
511
+
and also the same [sort](#sort) parameter (`--sort`). You can also run any previous `quick` search.
512
+
They don't have names (the ID is just used as the name), but they are saved in the system and can be
513
+
executed again. Searches (except those with an end date that has passed) show new results
514
+
if run later and match newly acquired imagery.
515
+
516
+
### Update Search
517
+
518
+
You can also update an existing search to have a different set of values. This takes similar arguments, and
519
+
will overwrite the previous values.
520
+
521
+
```
522
+
planet data filter --string-in instrument PS2,PSB.SD | planet data search-update da963039dbe94573a3ac9e4629d065b6 --name 'my updated search' --filter - SkySatCollect
523
+
```
524
+
525
+
### Delete Search
526
+
527
+
If you're no longer using a search you can delete it:
528
+
529
+
```
530
+
planet data search-delete da963039dbe94573a3ac9e4629d065b6
531
+
```
349
532
350
-
TODO
533
+
If the deletion was successful the command-line won't print out anything except a new line. If the
534
+
search didn't exist it will say `Error: {"general": [{"message": "The requested search id does not exist"}], "field": {}}`.
535
+
You can also delete `quick` searches, which would remove them from your history.
0 commit comments