Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
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
3866eb1a
Commit
3866eb1a
authored
Dec 16, 2023
by
Mario Chirinos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new api
parent
1eccc82b
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
205 additions
and
38 deletions
+205
-38
config.json
config/config.json
+1
-1
APISentinel.py
geosentinel/APISentinel.py
+2
-2
.s3cfg
geosentinel/SentinelHub/.s3cfg
+8
-0
sentielhub.py
geosentinel/SentinelHub/sentielhub.py
+88
-0
cloudFreeWKT.py
geosentinel/cloudFreeWKT.py
+19
-0
setup.py
setup.py
+12
-35
downloadWKT.sh
tools/downloadWKT.sh
+75
-0
No files found.
config/config.json
View file @
3866eb1a
{
"PATHS"
:
{
"PATH_GEOSENTINEL"
:
"/home/
david/centroGEO/repsa
t/GeoSentinel"
,
"PATH_GEOSENTINEL"
:
"/home/
mchc/gi
t/GeoSentinel"
,
"PATH_NAS"
:
"/home/david/NAS/"
},
"API_SENTINEL"
:
{
...
...
geosentinel/APISentinel.py
View file @
3866eb1a
...
...
@@ -17,7 +17,7 @@ from datetime import date
from
collections
import
OrderedDict
import
time
#from osgeo import ogr
'C4+rC@W>7C5s$b'
class
APISentinel
(
object
):
""" Class for Sentinel satellites configuration
...
...
geosentinel/SentinelHub/.s3cfg
0 → 100644
View file @
3866eb1a
[default]
access_key = YZ7UPLDGVGGSHQTXSIUN
host_base = eodata.dataspace.copernicus.eu
host_bucket = eodata.dataspace.copernicus.eu
human_readable_sizes = False
secret_key = Y00yNywqhBKQYiiSRc6R4bcj0iqeE1qcEIOZxdhE
use_https = true
check_ssl_certificate = true
geosentinel/SentinelHub/sentielhub.py
0 → 100644
View file @
3866eb1a
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import
sys
from
oauthlib.oauth2
import
BackendApplicationClient
from
requests_oauthlib
import
OAuth2Session
import
json
#Access key
#YZ7UPLDGVGGSHQTXSIUN
#Secret key
#Y00yNywqhBKQYiiSRc6R4bcj0iqeE1qcEIOZxdhE
#===============================================================================
def
sentinelhub_compliance_hook
(
response
):
response
.
raise_for_status
()
return
response
def
example
():
# Your client credentials
client_id
=
'sh-933e0ce8-1d52-487b-aa33-358524d21cee'
client_secret
=
'R4a8WW4cuUPVdJXZGwr0BU5QfyMLho9l'
# Create a session
client
=
BackendApplicationClient
(
client_id
=
client_id
)
oauth
=
OAuth2Session
(
client
=
client
)
oauth
.
register_compliance_hook
(
"access_token_response"
,
sentinelhub_compliance_hook
)
# Get token for the session
token
=
oauth
.
fetch_token
(
token_url
=
'https://identity.dataspace.copernicus.eu/auth/realms/CDSE/protocol/openid-connect/token'
,
client_secret
=
client_secret
)
# All requests using this session will have an access token automatically added
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)
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
]
]
]
},
"datetime"
:
"2023-08-01T00:00:00Z/2023-12-10T23:59:59Z"
,
"collections"
:
[
"sentinel-2-l2a"
],
"limit"
:
5
,
"next"
:
5
,
"filter"
:
"eo:cloud_cover<5"
,
# "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
(
response
)
#===============================================================================
def
main
(
argv
):
# if len(sys.argv) != 2:
# print ("Usage text")
# else:
example
()
if
__name__
==
"__main__"
:
main
(
sys
.
argv
)
geosentinel/cloudFreeWKT.py
0 → 100644
View file @
3866eb1a
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import
sys
#from myModule import myModule
#===============================================================================
def
cloudFreeWKT
(
text
):
print
()
#===============================================================================
def
main
(
argv
):
if
len
(
argv
)
!=
2
:
print
(
"Usage text"
)
else
:
cloudFreeWKT
(
argv
[
1
])
if
__name__
==
"__main__"
:
main
(
sys
.
argv
)
setup.py
View file @
3866eb1a
# Copyright (C) 2018 Adan Salazar <asalazargaribay@gmail.com>
#
#
# This file is part of GeoSentinel
#
#
# GeoSentinel is free software you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GeoSentinel is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with StereoVision. If not, see <http://www.gnu.org/licenses/>.
from
setuptools
import
setup
setup
(
name
=
"geosentinel"
,
version
=
"1.0"
,
description
=
(
"Library and utilities for Sentinel products"
),
author
=
"
Adan Salazar
"
,
author_email
=
"
asalazargaribay@gmail.com
"
,
author
=
"
Mario Chirinos Colunga
"
,
author_email
=
"
mchirinos@centrogeo.edu.mx
"
,
packages
=
[
"geosentinel"
],
url
=
"none"
,
download_url
=
"none"
,
license
=
"GNU GPL"
,
#requires=["numpy"],
provides
=
[
"geosentinel"
],
classifiers
=
[
"Development Status :: 5 - Production/Stable"
,
classifiers
=
[
"Natural Language :: English"
,
"Operating System :: OS Independent"
,
"Programming Language :: Python :: 2"
,
"Intended Audience :: Developers"
,
"Intended Audience :: Education"
,
"Programming Language :: Python :: 3"
,
"Intended Audience :: Science/Research"
,
"License :: Freely Distributable"
,
"License :: OSI Approved :: GNU General Public License v3 "
"or later (GPLv3+)"
,
"Natural Language :: English"
,
"Operating System :: OS Independent"
,
"Programming Language :: Python :: 2.7"
,
"Topic :: Multimedia :: Graphics :: Capture"
])
"Natural Language :: English"
])
tools/downloadWKT.sh
0 → 100755
View file @
3866eb1a
#!/bin/sh
CFG
=
$1
#BYTILE=${2:-0}
CWD
=
$PWD
"/"
RED
=
'\033[0;31m'
NC
=
'\033[0m'
# No Color
echo
"
${
RED
}
Downloding WKT area from Sentinel-Hub
${
NC
}
"
echo
$CFG
wkt
=
$(
jq
-r
.wkt
$CFG
)
SORT
=
$(
jq
-r
.productsort
$CFG
)
echo
"wkt: "
echo
$wkt
#0.- Create Shape File From WKT
echo
"
${
RED
}
Creating Shape file...
${
NC
}
"
if
[
-d
"myshape"
]
;
then
rm
-r
myshape
fi
wktToShape.py
$CFG
"myshape"
#1.- Link L2A products
echo
${
RED
}
"Linking Products..."
${
NC
}
if
[
!
-d
"L2A"
]
;
then
mkdir
L2A
fi
cd
L2A
rm
*
cd
..
yes yes
| findProducts.py
$CFG
#2.- Extract Images
echo
"sort: "
$SORT
echo
${
RED
}
"Extracting JP2 Images..."
${
NC
}
if
[
!
-d
"jp2"
]
;
then
mkdir
jp2
fi
if
[
"
$SORT
"
!=
"date"
]
;
then
echo
"BY TILE"
#tile/date
L2AProductListExtractData.sh
$CWD
"L2A/"
$CWD
"jp2/"
4 1
else
echo
"BY DATE"
L2AProductListExtractData.sh
$CWD
"L2A/"
$CWD
"jp2/"
4 0
fi
echo
"sort: "
$SORT
cd
$CWD
#3.- Merge Images
echo
${
RED
}
"
\n
Merging Images..."
${
NC
}
if
[
!
-d
"wkt"
]
;
then
mkdir
"wkt"
fi
if
[
"
$SORT
"
!=
"date"
]
;
then
echo
"BY TILE"
# cd "jp2/"
# ls -d */ | parallel -q --jobs 1 mergeImagesByDirectory.sh $USERDIR"jp2/"{} "$wtk" 4
for
i
in
$(
ls
-d
*
/
)
;
do
if
[
!
-d
"../out/"
$i
]
;
then
mkdir
"../out/"
$i
fi
mergeImagesByDirectory.sh
$CWD
"jp2/"
$i
../../../out/
$i
"
$wkt
"
done
else
echo
"BY DATE"
# cd "jp2/"
mergeImagesByDirectory.sh
$CWD
"jp2/"
$CWD
"wkt/"
"
$wkt
"
1
fi
echo
"END"
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