Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
GeoSentinel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mario Chirinos Colunga
GeoSentinel
Commits
c24c7e0e
Commit
c24c7e0e
authored
1 year ago
by
Mario Chirinos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new api
parent
a7b5a1be
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
26 deletions
+49
-26
downloadlist.sh
geosentinel/SentinelHub/downloadlist.sh
+6
-0
sentielhub.py
geosentinel/SentinelHub/sentielhub.py
+43
-26
No files found.
geosentinel/SentinelHub/downloadlist.sh
0 → 100644
View file @
c24c7e0e
cat
$2
|
while
read
line
do
s3cmd
-c
$1
-r
get l
done
This diff is collapsed.
Click to expand it.
geosentinel/SentinelHub/sentielhub.py
View file @
c24c7e0e
...
...
@@ -30,49 +30,66 @@ def example():
client_secret
=
client_secret
)
# 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/"
)
# 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
)
resp
=
oauth
.
get
(
url
)
print
(
json
.
dumps
(
json
.
loads
(
resp
.
content
),
indent
=
2
)
)
data
=
{
# "bbox": [13, 45, 14, 46],
"intersects"
:{
"type"
:
"Polygon"
,
"coordinates"
:
[
[
[
-
92.3257000014545
,
22.585951489135
],
[
-
87.5331452799085
,
22.585951489135
],
[
-
87.5331452799085
,
20.7342113103226
],
[
-
92.3257000014545
,
20.7342113103226
],
[
-
92.3257000014545
,
22.585951489135
]
[
-
90.43670654296876
,
21.076811782249436
],
[
-
89.65667724609375
,
21.37635972888924
],
[
-
89.0606689453125
,
21.419833053493477
],
[
-
88.20648193359374
,
21.703369345524266
],
[
-
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"
:
"20
23-08-01T00:00:00Z/2023
-12-10T23:59:59Z"
,
"datetime"
:
"20
19-01-01T00:00:00Z/.."
,
#"2019
-12-10T23:59:59Z",
"collections"
:
[
"sentinel-2-l2a"
],
"limit"
:
5
,
"next"
:
5
,
"filter"
:
"eo:cloud_cover<5"
,
"limit"
:
100
,
"filter"
:
"eo:cloud_cover<3"
,
# "fields": {"include":["links"]},
}
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
)
#===============================================================================
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment