Commit c24c7e0e authored by Mario Chirinos's avatar Mario Chirinos

new api

parent a7b5a1be
cat $2 | while read line
do
s3cmd -c $1 -r get l
done
...@@ -30,49 +30,66 @@ def example(): ...@@ -30,49 +30,66 @@ def example():
client_secret=client_secret) client_secret=client_secret)
# All requests using this session will have an access token automatically added # All requests using this session will have an access token automatically added
# url = "https://sh.dataspace.copernicus.eu/api/v1/catalog/1.0.0/search"
# url = "https://sh.dataspace.copernicus.eu/api/v1/catalog/1.0.0/"
url = "https://sh.dataspace.copernicus.eu/api/v1/catalog/1.0.0/collections/sentinel-2-l2a/queryables"
# url = "https://sh.dataspace.copernicus.eu/api/v1/catalog/1.0.0/collections/sentinel-2-l2a"
resp = oauth.get("https://sh.dataspace.copernicus.eu/api/v1/catalog/1.0.0/") resp = oauth.get(url)
# print(json.dumps(json.loads(resp.content), indent=2))
# resp = oauth.get("https://sh.dataspace.copernicus.eu/api/v1/catalog/1.0.0/collections/sentinel-2-l2a/queryables")
# print(resp.content) print(json.dumps(json.loads(resp.content), indent=2))
data = { data = {
# "bbox": [13, 45, 14, 46], # "bbox": [13, 45, 14, 46],
"intersects":{ "intersects":{
"type": "Polygon", "type": "Polygon",
"coordinates": [ "coordinates": [
[ [
[-92.3257000014545, 22.585951489135 ], [-90.43670654296876, 21.076811782249436],
[-87.5331452799085, 22.585951489135 ], [-89.65667724609375, 21.37635972888924 ],
[-87.5331452799085, 20.7342113103226], [-89.0606689453125 , 21.419833053493477],
[-92.3257000014545, 20.7342113103226], [-88.20648193359374, 21.703369345524266],
[-92.3257000014545, 22.585951489135 ] [-87.79449462890625, 21.619132728904603],
[-87.53631591796875, 21.53995662308543 ],
[-87.53631591796875, 21.460737306938086],
[-90.25543212890625, 20.8639448490769 ],
[-90.450439453125 , 20.840844707411335],
[-90.43670654296876, 21.076811782249436]
] ]
] ]
}, },
"datetime": "2023-08-01T00:00:00Z/2023-12-10T23:59:59Z", "datetime": "2019-01-01T00:00:00Z/..", #"2019-12-10T23:59:59Z",
"collections": ["sentinel-2-l2a"], "collections": ["sentinel-2-l2a"],
"limit": 5, "limit": 100,
"next":5, "filter": "eo:cloud_cover<3",
"filter": "eo:cloud_cover<5",
# "fields": {"include":["links"]}, # "fields": {"include":["links"]},
} }
url = "https://sh.dataspace.copernicus.eu/api/v1/catalog/1.0.0/search" url = "https://sh.dataspace.copernicus.eu/api/v1/catalog/1.0.0/search"
response = oauth.post(url, json=data)
print(json.loads(response.content)["links"])
print("next", response.next)
print("FEATURES:",len(json.loads(response.content)["features"]))
for i in json.loads(response.content)["features"]:
print(i["id"], i["properties"]["eo:cloud_cover"], i["properties"]["datetime"])
print(i.keys())
print(json.dumps(i, indent=2))
# while response.status_code==200:
# response = oauth.post(url, json=data)
# print(json.loads(response.content)["links"])
# print("FEATURES:",len(json.loads(response.content)["features"]))
# for i in json.loads(response.content)["features"]:
# print(i["id"], i["properties"]["eo:cloud_cover"], i["properties"]["datetime"])
## print(i.keys())
# print(i["assets"]["data"]["href"])
productList = []
response = None
while response is None or response.status_code==200:
response = oauth.post(url, json=data)
content = json.loads(response.content)
for i in json.loads(response.content)["features"]:
# print(i["assets"]["data"]["href"])
productList.append(i["assets"]["data"]["href"])
if "next" in content["context"]:
data["next"]= content["context"]["next"]
print(content["context"])
else:
break;
with open("productList.txt", 'w') as fp:
for item in productList:
fp.write("%s\n" % item)
print(response) print(response)
#=============================================================================== #===============================================================================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment