Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick-search rogue field #137

Open
cdbarker opened this issue Jul 7, 2020 · 2 comments
Open

Quick-search rogue field #137

cdbarker opened this issue Jul 7, 2020 · 2 comments

Comments

@cdbarker
Copy link

cdbarker commented Jul 7, 2020

Running the following code based on the example jupyter notebook:

import os
import json
import requests
from requests.auth import HTTPBasicAuth

geojson_geometry = {
"type": "Polygon",
"coordinates": [
[
[
-122.43576049804688,
37.51299386065851
],
[
-122.34786987304686,
37.155938651244625
],
[
-122.07595825195312,
36.948794297566366
],
[
-121.8878173828125,
37.18110808791507
],
[
-122.43576049804688,
37.51299386065851
]
]
]
}

geometry_filter = {
"type": "GeometryFilter",
"field_name": "geometry",
"config": geojson_geometry
}

date_range_filter = {
"type": "DateRangeFilter",
"field_name": "acquired",
"config": {
"gte": "2018-03-01T00:00:00.000Z",
"lte": "2018-04-30T00:00:00.000Z"
}
}

cloud_cover_filter = {
"type": "RangeFilter",
"field_name": "cloud_cover",
"config": {
"lte": 0.5
}
}

combined_filter = {
"type": "AndFilter",
"config": [geometry_filter, date_range_filter, cloud_cover_filter]
}

os.environ['PL_API_KEY']=''
PLANET_API_KEY = os.getenv('PL_API_KEY')

item_type = "PSScene4Band"

search_request = {
"interval": "day",
"item_types": [item_type],
"filter": combined_filter
}

search_result = requests.post(
'https://api.planet.com/data/v1/quick-search',
auth=HTTPBasicAuth(PLANET_API_KEY, ''),
json=search_request)
print(json.dumps(search_result.json(), indent=1))

The response is:

{
"general": [
{
"message": "{"interval": "Rogue field"}"
}
],
"field": {}
}

However, the above code with https://api.planet.com/data/v1/stats as the request URL instead returns expected results.

@tdk8823
Copy link

tdk8823 commented Jul 8, 2020

I met the same error.
I avoided the error to comment out "interval": "day" in search_request.

@cdbarker
Copy link
Author

cdbarker commented Jul 8, 2020

@tdk8 thanks so much!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants