Ordering Planet Data - Command Line to API

Derived from: https://planetlabs.github.io/planet-client-python/cli/examples.html


To install:

  • pip install planet

  • planet init

    • log in with usename/password credentials


Ensure you have your API KEY set up (may not be necessary if logged in as above).

  • Set this as a system variable

    • In python:

      • os.environ['PL_API_KEY']='12345'

    • In BASH:

      • PL_API_KEY = '12345'


Make list of scenes to order

  • planet data search --item-type PSScene --geom /Users/dan.sousa/Downloads/map.geojson --date acquired gt 2015-01-01 --date acquired lt 2017-01-01 --range cloud_cover lt .1

    • --item-type specifies the dataset type (PSScene or orthotile; 3 or 4 or 8 band)

    • --geom specifies the path to the geojson defining the study area

    • --date acquired gt is the beginning of the order window

    • --date acquired lt is the end of the order window

    • --range cloud_cover lt is cloud cover (less than % of scene)


Save the order

  • planet data create-search --item-type PSScene --geom /Users/dan.sousa/Downloads/map.geojson --date acquired gt 2015-01-01 --date acquired lt 2017-01-01 --range cloud_cover lt .1 --asset-type analytic_sr

    • --item-type specifies the dataset type (PSScene or orthotile; 3 or 4 or 8 band)

    • --geom specifies the path to the geojson defining the study area

    • --date acquired gt is the beginning of the order window

    • --date acquired lt is the end of the order window

    • --range cloud_cover lt is cloud cover (less than % of scene)

    • --asset-type specifies the processing type (analytic_sr is surface reflectance; analytic is TOA)



Execute the saved search order

  • planet data saved-search <4782d4118fee4275860665129a1e23c1>

    • Replace <4782d4118fee4275860665129a1e23c1> with search # from previous command, like

Download the order

  • planet data download --item-type PSScene asset-type analytic_sr --dest /Users/dan.sousa/Downloads/NewPlanet

    • --item-type specifies the dataset type (PSScene or orthotile; 3 or 4 or 8 band)

    • --asset-type specifies the processing type (analytic_sr is surface reflectance; analytic is TOA)

    • --dest specifies the download location


Convert to common (WGS84) projection and ENVI format

  • for i in *math.tif; do gdalwarp -t_srs EPSG:4326 -of ENVI ${i} ${i}_e; done

    • Assumes files of interest end in "math.tif"

    • WGS-84 (lat/lon) is set using the EPSG code. Pick another if you want a different projection.

    • Assumes ENVI-formatted output


Pull out 1 of the bands

  • for i in *_e; do gdal_translate -b 1 -of ENVI ${i} ${i}EVI2; done

    • Assumes you want band 1. Change the number after -b to change the band


Stack all the single-band images into a single multiband timeseries

  • gdal_merge.py -o 2020_2021_PlanetSedg_EVI2stack -separate -of ENVI *_eEVI2