Planet easy to use Python library and interface to access the Public APIs via Command Line.
- With PIP
pip install --user planet- With conda
conda install -c conda-forge planetWe will be using jq command line tool a lot. So make sure you have it installed
Using your Planet credentials
planet init
Email:
Password:You can also use your Planet API key on each call with the argument -k
planet -k YOUR_API_KEY command subcommandplanet data --helpGet the most recently published PSScene3Band
planet data search --item-type PSScene3BandItem-type input is case-insensitive
planet data search --item-type psscene*planet data search --item-type ps*By default, pretty printing is enabled.
Get guidance on input argument options of each API subcommand
planet data create-search --helpplanet data create-search --name workshop-saved-1 --item-type PSScene4Band --geom sf.geojson --date acquired gte 2019-10-01 --date acquired lt 2019-10-04Use jq to parse JSON result and filter search metadata
planet data searches | jq .searches[].nameWe need to first get a saved-search ID to run it
planet data searches | jq .searches[].idThen we can use use the CLI to execute the search. We can again use jq to just check how many items we got
planet data saved-search 71687dd9711a4b80a444a99871534155 | jq '.features | length'Let's have a look at the optiosn we have when it comes to downloading
planet data download --helpExecute a search and download the resulting items
planet data download --item-type PSScene4Band --asset-type analytic --geom cali.geojson --range cloud_cover lte 0.4 --date acquired gt 2019-10-14 --dry-runWe can also assess our data locally by exporting the image metadata, geometry included
planet data search --item-type PSScene4Band --asset-type analytic --geom cali.geojson --range cloud_cover lte 0.4 --date acquired gt 2019-10-14 --limit 4000 > g.jsonThen we can go and download only what we want to download
planet data download --item-type PSScene4Band --asset-type analytic --geom cali.geojson --range cloud_cover lte 0.4 --date acquired gt 2019-10-14 --string-in satellite_id 0f34We can run it on verbose mode too
planet -v data download --item-type PSScene4Band --asset-type analytic --geom cali.geojson --range cloud_cover lte 0.4 --date acquired gt 2019-10-14 --string-in satellite_id 0f34 --quietDownload a single image
planet -v data download --item-type PSScene4Band --asset-type analytic --string-in id 20191014_183506_0f34 --quietWe can save a filter as a json file for us to use later
planet data filter --range cloud_cover lt 0.1 --geom cali.geojson > my-search.jsonCreate a search using the saved filter
planet data create-search --item-type PSScene3Band --string-in satellite_id 0c12 --name my-search --filter-json my-search.jsonplanet orders --helpSimply, submit a job to Orders API
planet orders create --item-type PSScene4Band --bundle analytic_sr_udm2 --id 20191014_183506_0f34 --name ws-simple-1Using an order ID, we can monitor its progress
planet orders get 20ce4bad-a52e-451e-8f9d-5f4c1559e0d6 | jq '"Name: " + .name + ". Status: " + .state'Before going into running status, orders go into queue. In this state, orders can be canceled
planet orders cancel f66ccd7b-ae64-40dd-b16b-45d10736e280With the Orders API, we can get already processed data such as NDVI maps
planet orders create --item-type PSScene4Band --bundle analytic_sr_udm2 --id 20191014_183506_0f34 --name ws-bandmath-1 --tools bandmath.jsonWe can check all of our orders in bulk
planet orders list | jq '.orders[] | "Name: " + .name + ". Status: " + .state 'If we do not want to check orders regularly, we can make use of email notification
planet -k $K orders create --item-type PSScene4Band --bundle analytic_sr_udm2 --id 20191014_183506_0f34 --name ws-bandmath-email-1 --tools bandmath.json --emailOnce an order is ready, we can download it to a desired directory
planet orders download 175373e2-0fdf-4de4-b6d2-d54747905e25 --dest ws-bandmath-email --quietWe can also extract order metadata, for instance it's clipped geometry
planet -k $K orders get 3bb87e78-a55c-40af-86b3-3767b427d0d5 | jq '{"type": "Feature", "geometry": .tools[].clip.aoi }' > aoi.jsonplanet mosaics listplanet mosaics info global_monthly_2018_09_mosaic(Omitting the --limit option will list all quads. Keep in mind that there may be millions for a global mosaic.)
planet mosaics search global_monthly_2018_09_mosaic --limit=10planet mosaics search global_monthly_2018_09_mosaic --rbox=-95.5,29.6,-95.3,29.8Note that the format of --bbox is "xmin,ymin,xmax,ymax", so longitude comes before latitude.
planet mosaics download global_monthly_2018_09_mosaic --bbox=-95.5,29.6,-95.3,29.8Unless there is a basemap series set up in the subscription, this will not work
planet mosaics series describe 0beb88b8-4d08-464a-a8a6-9848de9585e8planet mosaics series list-mosaics 0beb88b8-4d08-464a-a8a6-9848de9585e8