Last active
February 19, 2018 21:10
-
-
Save danabauer/fbfbee640d1fbdbaabad9ef037a95ae4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
geo_json_geometry = { | |
"type": "Polygon", | |
"coordinates": [ | |
[ | |
[ | |
-120.8551025390625, | |
36.6551995018735 | |
], | |
[ | |
-120.13549804687501, | |
36.6551995018735 | |
], | |
[ | |
-120.13549804687501, | |
37.081475648860525 | |
], | |
[ | |
-120.8551025390625, | |
37.081475648860525 | |
], | |
[ | |
-120.8551025390625, | |
36.6551995018735 | |
] | |
] | |
] | |
} | |
# filter for items the overlap with our chosen geometry | |
geometry_filter = { | |
"type": "GeometryFilter", | |
"field_name": "geometry", | |
"config": geo_json_geometry | |
} | |
sat_id_filter = { | |
"type":"StringInFilter", | |
"field_name":"satellite_id", | |
"config":[ | |
"0f10", | |
"0f12", | |
"0f17", | |
"0f18" | |
] | |
} | |
# create a filter that combines our geo and date filters | |
# could also use an "OrFilter" | |
satid_geo_filter = { | |
"type": "AndFilter", | |
"config": [sat_id_filter, geometry_filter] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import requests | |
from requests.auth import HTTPBasicAuth | |
# our demo filter that filters by geometry, date and cloud cover | |
import satid_geo_filter | |
# Search API request object | |
search_endpoint_request = { | |
"item_types": ["PSScene4Band"], | |
"filter": satid_geo_filter | |
} | |
result = \ | |
requests.post( | |
'https://api.planet.com/data/v1/quick-search', | |
auth=HTTPBasicAuth(os.environ['PL_API_KEY'], ''), | |
json=search_endpoint_request) | |
print result.text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment