Commit 3866eb1a authored by Mario Chirinos's avatar Mario Chirinos

new api

parent 1eccc82b
{ {
"PATHS": { "PATHS": {
"PATH_GEOSENTINEL": "/home/david/centroGEO/repsat/GeoSentinel", "PATH_GEOSENTINEL": "/home/mchc/git/GeoSentinel",
"PATH_NAS": "/home/david/NAS/" "PATH_NAS": "/home/david/NAS/"
}, },
"API_SENTINEL": { "API_SENTINEL": {
......
...@@ -17,7 +17,7 @@ from datetime import date ...@@ -17,7 +17,7 @@ from datetime import date
from collections import OrderedDict from collections import OrderedDict
import time import time
#from osgeo import ogr #from osgeo import ogr
'C4+rC@W>7C5s$b'
class APISentinel(object): class APISentinel(object):
""" Class for Sentinel satellites configuration """ Class for Sentinel satellites configuration
......
[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
#!/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)
#!/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)
# 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 from setuptools import setup
setup(name="geosentinel", setup(name="geosentinel",
version="1.0", version="1.0",
description=("Library and utilities for Sentinel products"), description=("Library and utilities for Sentinel products"),
author="Adan Salazar", author="Mario Chirinos Colunga",
author_email="asalazargaribay@gmail.com", author_email="mchirinos@centrogeo.edu.mx",
packages=["geosentinel"], packages=["geosentinel"],
url="none", url="none",
download_url="none", download_url="none",
license="GNU GPL", license="GNU GPL",
#requires=["numpy"], #requires=["numpy"],
provides=["geosentinel"], provides=["geosentinel"],
classifiers=["Development Status :: 5 - Production/Stable", classifiers=[
"Natural Language :: English", "Natural Language :: English",
"Operating System :: OS Independent", "Operating System :: OS Independent",
"Programming Language :: Python :: 2", "Programming Language :: Python :: 3",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research", "Intended Audience :: Science/Research",
"License :: Freely Distributable", "License :: Freely Distributable",
"License :: OSI Approved :: GNU General Public License v3 " "License :: OSI Approved :: GNU General Public License v3 "
"or later (GPLv3+)", "or later (GPLv3+)",
"Natural Language :: English", "Natural Language :: English"
"Operating System :: OS Independent", ])
"Programming Language :: Python :: 2.7",
"Topic :: Multimedia :: Graphics :: Capture"])
#!/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}"\nMerging 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"
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