Skip to main content

Hi Planet Community,

My team and I are trying to download clipped and harmonized imagery through the API, the clip tool is running but the harmonized isn’t.

We are working with the Surface Reflectance product bundle, so we defined Sentinel - 2 as the target sensor.

Below, are the screenshots of the code we are using in Visual Studio IDLE. The goal is to integrate the workflow into an ArcGIS Toolbox.

If anyone has worked with this tool or knows the reason why our code is failing we’ll be glad for the help.

Thanks in advance.

 

Welcome to the Planet Community!

 

I don’t see anything obviously wrong with your request, what is the error that you’re seeing when you submit it?

I just submitted a request and it worked.

My request looks like:

 

See it at https://gist.github.com/cholmes/f4e50de03922dea5a9106f3ab649e000

 

If you could share some output from your code that shows a valid request with clipping working and an invalid request with harmonization on I should be able to help.


Hi @cholmes, thanks for your help!

We checked your code and has the same structure as ours, we tried again but got the same result. 

The toolbox’s execution goes well with the clip tool, but we got this error when we try to add the harmonization (The status of the request is 400):

We hope this could help to deepen the case. Our best regards.


Can you share the JSON in text? Like attach (or post as a gist like I did) the request made that has the harmonize & clip calls with the aoi in it, so I can try to run it on my end? And/or paste in the error response the server is returning.


Thanks again @cholmes  for your reply and your valuable help 🙂

Unfortunately, we’ve been working on this toolbox and noticed that the output folder is empty even when the state of the process is “success” for the clip tool. We have a simpler version of the script just to download 4 band scenes, this is our base to implement the PSScene product and the clip and harmonized tools. To share our resources, in this reply we provide a link to a folder where are both files in .pyt format, Download is the initial script, and Download 2 is the version we want to implement with the improvements we comment you.

Google Drive Folder

Best regards.


Interesting. Unfortunately I don’t have arcpy so I don’t think I can actually run the script. 

Would it be possible for you to run both versions of your program but add in a line that prints out the ‘order’ variable, like the JSON that gets sent to the server, and share that with me? 

 

If it does say the process is ‘success’ then it sounds like perhaps your download isn’t working? Can you check https://www.planet.com/account/#/orders and click through on your order (or if you know the id you can just go to https://www.planet.com/account/#/orders/<order-id>). Can you download the results from there? If so then it’d just be that download isn’t working.

Happy to jump on a zoom to try to look this over together, will send you my contact info in a private message.


I am having the same issue. Please see below the code:

request = {  
"name":"harmonized",
"products":[
{
"item_ids":all_ids,
"item_type":"PSScene4Band",
"product_bundle":"analytic_sr_udm2"
}
],

"tools":[
{"clip": {
"aoi": multipoly}},
{"harmonize": {
"target_sensor": "Sentinel-2"}}
]
}

order_url = place_order(request, auth)

and I get the following error:

---> 1 order_url = place_order(request, auth)  


2 response = requests.post(orders_url, data=json.dumps(request), auth=auth, headers=headers)
3 print(response)
----> 4 order_id = response.json())'id']
5 print(order_id)
6 order_url = orders_url + '/' + order_id

KeyError: 'id'

It works fine if I just use the Clip tool. Was anyone else able to resolve this?

Thank you!


Hey @asing075 - I’m talking to the original poster on thursday to try to work through the issue. 


I’d be happy to set up a call with you as well, or to just post here once we (hopefully) figure it out.

 

Also if you’re able to share the actual ‘request’ that gets sent that can help me debug it, along with what the json error response you’re seeing is.

 

asing075 - is there a reason you’re using PSScene4Band instead of PSScene? (and using ortho_analytic_8b_sr or ortho_analytic_4b_sr). See https://developers.planet.com/docs/subscriptions/tools/#harmonization​​​​​​ I don’t _think_ that’s your problem, but in general we’re recommending everyone to move to PSScene. See https://developers.planet.com/docs/apis/data/psscene3-4band-deprecation/

best regards,

Chris


@asing075 - Just talked to the core team, and they said that if you want to use Sentinel-2 as the harmonization target then you need to use PSScene. PSScene4Band only supports PS2 as the sensor target, see https://developers.planet.com/apis/orders/tools-reference/#harmonization (apologies for the wrong link above - meant to link to the orders tool). 

PSScene is better in just about every way, so I’d recommend just shifting your code / workflows to using PSScene.


Hi @cholmes , Thank you for pointing that out! Below are the changes I made to the my search filter and order:

Search
Order

I think this should do it, but just wanted to confirm with you first. Please let me know if you notice anything wrong


It’s hard to confirm 100% just by looking at the code, but it looks right to me.  


 Thank you @cholmes, It is working for me now.  

 

 


Hi everyone! As @chrisholmes said, we met the Planet team some days ago and they help us find the error. We were missing some divisions in our script which impede the order was successfully received. The correct way to call the tools is the following:

       "tools": o
                {
                "harmonize": {
                    "target_sensor": "Sentinel-2"
                }
                },
                { "clip": {"aoi":roi} }
            ]

Thanks for your invaluable support! Our best regards.


Reply