Using and Building with Planet’s new Ordersv2 API: Including replacement to Clip & Ship

Comments

15 comments

  • Jeremy Metcalf

    Nice!

  • Samapriya Roy

    In the spirit of writing cheat sheets, here's to the porder tool to work with ordersv2. Download the full pdf version here.

    I updated this to v0.0.8

  • Jeffrey Himel

    Hey Samapriya,

    Thanks for your efforts in creating the alternative to Clip and Ship.


    We've tried following your instructions, but are not having success. The description of the problem from our web developer is as follows:

    The article is missing a section on how to install the Planet CLI, so I followed the instructions here:
     
     
    Those would indicate that I should just be able to use the "planet" command on the terminal after the install, but it wasn't found. So then I located the directory where the CLI was installed and tried issuing the command from there which also said it wasn't found, so then tried running the program with the command below, which accessed the program but returned an error:
     
    Command: python planet data download --activate-only --item-type PSScene4Band --asset-type visual --string-in id 20190102_030530_1042 --quiet
    Error: /usr/bin/python: can't find '__main__' module in 'planet'
     
    Tried doing some Googling to find a solution but no luck. What is supposed to happen is that after you run "pip install planet" there should be a command line app that can be launched by typing "planet", but that doesn't happen. I can see the install has happened as the files have been created in "~/.local/lib/python3.6/site-packages/planet" but the command line tool doesn't work.

    Any ideas?

    Best Regards,

    Jeffrey


     
  • Samapriya Roy

    Hi Jeffrey,

    Couple of things to consider here

    1. What is your operating system and what is the default python on that system? you can usually find out that by typing python on your terminal or command prompt. So make sure you can actually access python in your command prompt or terminal by typing 
      python
      and note down the default python.

    2. The next step depending on your OS is to make sure that you use the right pip, a system can have both pip2 and pip3 for python2 and python3 setups on your system. So you might be able to install 
      pip install planet but also pip3 install planet
      The last step is to initialize the client. Your client will not work if you have not initialized, so type
      planet init and initialize your client.

    Hopefully, this will get the client sorted out for you, feel free to include more info and screenshots.

     

    Sam

  • Mylène Jacquemart

    Hi Sam,

    Amazing work you have been doing! All of these tools already feel so much more intuitive than the old API!

    I was just trying to run porder idlist, but it failed here:

    $ porder idlist --input "/data2/MtSulzer/PlanetData/glacier_only.json" --start '2010-07-20' --end '2016-09-30' --item 'REOrthoTile' --asset 'visual' --number '100' --cmin 0 --cmax 0.5 --overlap 100 --outfile '/data2/MtSulzer/PlanetData/planetsearch.csv'
    Could not parse geometry
    'config'
    Traceback (most recent call last):
    File "/usr/bin/porder", line 11, in <module>
    sys.exit(main())
    File "/usr/lib/python2.7/site-packages/porder/porder.py", line 201, in main
    args.func(args)
    File "/usr/lib/python2.7/site-packages/porder/porder.py", line 70, in idlist_from_parser
    outfile=args.outfile)
    File "/usr/lib/python2.7/site-packages/porder/geojson2id.py", line 155, in idl
    data['filter']['config'][0]['config']['coordinates'] = aoi_geom
    UnboundLocalError: local variable 'aoi_geom' referenced before assignment

    Am I doing something wrong?

    Thanks!

  • Samapriya Roy

    Hi Mylene,

    Am glad you are enjoying the tool, I cannot comment without looking at the JSON file, but here are two things to consider

    1. Use a GeoJSON instead, try creating a polygon using geojson.io and download the file. Incase you are inclined to use a structured JSON, you can find an example here. The JSON already contains your cloud cover means you can even avoid cmin and cmax if you structure it the same way.This is the command  ran with this tool (do not copy and paste since that messes up the quotes depending on your terminal)

      porder idlist --input "C:\planet\aoi.json" --start "2018-01-01" --end "2018-12-01" --item "PSScene4Band" --asset "analytic" --number "25" --outfile "C:\planet\list.csv" --overlap 1

    2. This tool was designed to work with single polygon only and not multipolygon, so make sure you only use a single polygon, you can iterate over multiple GeoJSON files in a folder to get additional areas.

    By looking at the error , it seems to be a geometry error in trying to find the geometry for the file. So let me know if creating a new GeoJSON helped in any way. 

    Best Wishes,
    Sam

  • Mylène Jacquemart

    Hi Sam,

    Interesting. Indeed, just renaming the file to .geojson did the trick (I had made it with geojson.io but named it .json as per your example).

    Might be worth mentioning in the tutorial?

    Many thanks,
    Mylène

  • Samapriya Roy

    Hi Mylène,

    The tutorial only refers to geojson from geojson.io as mentioned in the medium article. Am glad it worked out for you though. Also for most updated tools within porder you should use the readme file from github

    https://github.com/samapriya/porder

    Best wishes,
    Sam

  • Mylène Jacquemart

    Hi Sam,

    Sorry to keep this conversation going, but I ran into the next problem running:

    porder order --name MyleneJacquemartFC --idlist /data2/MtSulzer/PlanetData/planetsearch.txt --item REOrthoTile --asset visual --boundary map.geojson --op clip email

    I get:

    {"field":null,"general":[{"message":"Unable to accept order: geojson: invalid geometry"}]}

    Here's what map.geojson looks like (downloaded from geojson.io):

    {
          "type": "FeatureCollection",
          "features": [
             {
                   "type": "Feature",
                   "properties": {},
                   "geometry": {
                      "type": "Polygon",
                      "coordinates": [
                         [
                           [
                               -141.58355712890625,
                               61.63079396120885
                          ],
                          [
                              -141.51935577392575,
                              61.63079396120885
                          ],
                          [
                             -141.51935577392575,
                             61.66071388941507
                          ],
                          [
                            -141.58355712890625,
                            61.66071388941507
                          ],
                          [
                            -141.58355712890625,
                            61.63079396120885
                          ]
                     ]
                 ]
              }
           }
        ]
    }

     

    Thank you very much for all your patience and help, it is much appreciated.

    Mylène

  • Samapriya Roy

    Hi Mylène,

    I think your setup was mostly correct however the --boundary setup has to include the full path to your map.geojson file. For example assuming that your file is in a location "/home/Downloads" then the setup would be 

    porder order --name MyleneJacquemartFC --idlist /data2/MtSulzer/PlanetData/planetsearch.txt --item REOrthoTile --asset visual --boundary "/home/Downloads/map.geojson" --op clip email

    Hope this helps fix the issue.

    Sam

  • Mylène Jacquemart

    Hi Sam,

    Thanks for your advice, but unfortunately it doesn't solve the problem... Here's the command:

    $ porder order --name MyleneJacquemartFC --idlist /data2/MtSulzer/PlanetData/planetsearch.txt --item REOrthoTile --asset visual --boundary /data2/MtSulzer/PlanetData/map.geojson --op clip email
    {"field":null,"general":[{"message":"Unable to accept order: geojson: invalid geometry"}]}

    I also tried various combinations of single and double quotes around the paths. I also validated my geojson here at http://geojsonlint.com/ and it shows up correctly.

    Any other ideas of what could be causing the error?

    Many thanks,

    Mylène

  • Samapriya Roy

    Hi Mylène,

    Indeed the clip functionality was broken when I updated the cloud delivery options. I will work on a fix and release it sometime later today? Check for release 0.0.9 sometime today or early tomorrow.

    Sam

  • Mylène Jacquemart

    Great, I will try again tomorrow. Thanks Sam!!

  • Mylène Jacquemart

    Hi Sam,

    Looks like you put up release 0.1.0? I cloned the github repos and installed porder from there (installation finished with Finished processing dependencies for porder==0.1.0)
    ). Then I successfully reinitialized the client with planet init. Additionally, I have this in my .bashrc file: export PL_API_KEY=a5bunch4of3numbers2and1letters

    The error that I get now reads:

    $ porder order --name MyleneJacquemartFC --idlist /data2/MtSulzer/PlanetData/planetsearch.txt --item REOrthoTile --asset visual --boundary /data2/MtSulzer/PlanetData/map.geojson --op clip email
    {"field":null,"general":[{"message":"Order request resulted in no acceptable assets. Likely due to lack of permissions."}]}

    Is there a way to check whether version 0.1.0 was correctly initialized with my password and email? Any other suggestions as to where it might stall now?

    Sorry for the hassle, it would be extremely useful to me if I was able to get the data before next week.

    Thanks!

    Mylène

  • Samapriya Roy

    Hi Mylene,

    Thank you for pointing this out, seems the text file read for idlist was introducing a new line character and I had to use strip() to clean that. Since there is no way to rerelease something on pypi I have uploaded v0.1.1.

    In the future, you should be able to initialize the client by simply using

    planet init followed by your email and password. This method is better in some way since it is independent of operating system that you use.

    The issue was not about permissions at your end, but simply the line not being interpreted properly. Also feel free to create Github issues in my repo in the future, since this is not an official Planet tool. I have tested it for your GeoJSON and with about 3 different RapidEye images to make sure the order does not fail. Hopefully, this resolves your issue.

     

    Sam

     

     

Please sign in to leave a comment.