teledetection 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- teledetection-0.1.0/.gitignore +12 -0
- teledetection-0.1.0/.gitlab-ci.yml +65 -0
- teledetection-0.1.0/LICENSE +201 -0
- teledetection-0.1.0/PKG-INFO +34 -0
- teledetection-0.1.0/README.md +28 -0
- teledetection-0.1.0/RELEASE_NOTES.txt +3 -0
- teledetection-0.1.0/doc/access.md +30 -0
- teledetection-0.1.0/doc/additional_resources.md +13 -0
- teledetection-0.1.0/doc/advanced.md +114 -0
- teledetection-0.1.0/doc/cli-ref.md +6 -0
- teledetection-0.1.0/doc/credentials.md +108 -0
- teledetection-0.1.0/doc/doc_requirements.txt +8 -0
- teledetection-0.1.0/doc/examples/__init__.py +1 -0
- teledetection-0.1.0/doc/examples/basic.md +23 -0
- teledetection-0.1.0/doc/examples/processing_examples_pyotb.md +144 -0
- teledetection-0.1.0/doc/examples/processing_examples_rasterio.md +75 -0
- teledetection-0.1.0/doc/examples/pyotb_ndvi_loss.py +32 -0
- teledetection-0.1.0/doc/examples/pyotb_toa_mosaic.py +23 -0
- teledetection-0.1.0/doc/examples/rio_metadata.py +32 -0
- teledetection-0.1.0/doc/examples/rio_ndvi.py +63 -0
- teledetection-0.1.0/doc/gen_ref_pages.py +24 -0
- teledetection-0.1.0/doc/index.md +49 -0
- teledetection-0.1.0/doc/logo.png +0 -0
- teledetection-0.1.0/doc/sample.md +233 -0
- teledetection-0.1.0/doc/sample.py +44 -0
- teledetection-0.1.0/doc/stylesheets/extra.css +5 -0
- teledetection-0.1.0/doc/upload.md +45 -0
- teledetection-0.1.0/mkdocs.yml +80 -0
- teledetection-0.1.0/pyproject.toml +60 -0
- teledetection-0.1.0/setup.cfg +4 -0
- teledetection-0.1.0/teledetection/__init__.py +21 -0
- teledetection-0.1.0/teledetection/cli.py +364 -0
- teledetection-0.1.0/teledetection/sdk/__init__.py +1 -0
- teledetection-0.1.0/teledetection/sdk/http.py +124 -0
- teledetection-0.1.0/teledetection/sdk/logger.py +15 -0
- teledetection-0.1.0/teledetection/sdk/model.py +119 -0
- teledetection-0.1.0/teledetection/sdk/oauth2.py +214 -0
- teledetection-0.1.0/teledetection/sdk/py.typed +0 -0
- teledetection-0.1.0/teledetection/sdk/settings.py +59 -0
- teledetection-0.1.0/teledetection/sdk/signing.py +507 -0
- teledetection-0.1.0/teledetection/sdk/utils.py +21 -0
- teledetection-0.1.0/teledetection/upload/__init__.py +1 -0
- teledetection-0.1.0/teledetection/upload/diff.py +102 -0
- teledetection-0.1.0/teledetection/upload/py.typed +0 -0
- teledetection-0.1.0/teledetection/upload/raster.py +351 -0
- teledetection-0.1.0/teledetection/upload/stac.py +420 -0
- teledetection-0.1.0/teledetection/upload/transfer.py +20 -0
- teledetection-0.1.0/teledetection.egg-info/PKG-INFO +34 -0
- teledetection-0.1.0/teledetection.egg-info/SOURCES.txt +56 -0
- teledetection-0.1.0/teledetection.egg-info/dependency_links.txt +1 -0
- teledetection-0.1.0/teledetection.egg-info/entry_points.txt +2 -0
- teledetection-0.1.0/teledetection.egg-info/requires.txt +20 -0
- teledetection-0.1.0/teledetection.egg-info/top_level.txt +1 -0
- teledetection-0.1.0/tests/Dockerfile.tests +5 -0
- teledetection-0.1.0/tests/docker-compose.yml +15 -0
- teledetection-0.1.0/tests/test_sdk.py +372 -0
- teledetection-0.1.0/tests/test_upload.py +376 -0
- teledetection-0.1.0/tests/utils.py +28 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
include:
|
|
2
|
+
- project: "cdos-pub/pycode-quality"
|
|
3
|
+
ref: "main"
|
|
4
|
+
file:
|
|
5
|
+
- ".gitlab/ci/static-analysis.yml"
|
|
6
|
+
- ".gitlab/ci/doc.yml"
|
|
7
|
+
- ".gitlab/ci/docker-compose-tests.yml"
|
|
8
|
+
- ".gitlab/ci/pip.yml"
|
|
9
|
+
|
|
10
|
+
default:
|
|
11
|
+
tags:
|
|
12
|
+
- armageddon
|
|
13
|
+
|
|
14
|
+
variables:
|
|
15
|
+
PYTHON_IMG: python:3.12-slim
|
|
16
|
+
PACKAGE_INSTALL_EXTRAS: "[test,upload]"
|
|
17
|
+
PIP_PACKAGE_URL: "https://upload.pypi.org/legacy/"
|
|
18
|
+
TWINE_USERNAME: __token__
|
|
19
|
+
TWINE_PASSWORD: ${PYPI_TOKEN}
|
|
20
|
+
DOCKER_COMPOSE_CHDIR: "tests"
|
|
21
|
+
|
|
22
|
+
DOC_BUILD_SELF: true
|
|
23
|
+
|
|
24
|
+
stages:
|
|
25
|
+
- Docker compose tests
|
|
26
|
+
- Test
|
|
27
|
+
- Static Analysis
|
|
28
|
+
- Documentation
|
|
29
|
+
- Pip
|
|
30
|
+
|
|
31
|
+
.static_analysis_base:
|
|
32
|
+
allow_failure: false
|
|
33
|
+
|
|
34
|
+
Tests with docker compose:
|
|
35
|
+
coverage: '/^TOTAL.+?(\d+\%)$/'
|
|
36
|
+
after_script:
|
|
37
|
+
- ls -lha
|
|
38
|
+
artifacts:
|
|
39
|
+
paths:
|
|
40
|
+
- .coverage
|
|
41
|
+
reports:
|
|
42
|
+
junit: report.xml
|
|
43
|
+
|
|
44
|
+
Code coverage:
|
|
45
|
+
stage: Static Analysis
|
|
46
|
+
image: python:3.10-slim
|
|
47
|
+
script:
|
|
48
|
+
- ls -lha
|
|
49
|
+
- mkdir /app
|
|
50
|
+
- cp -r . /app
|
|
51
|
+
- pip install coverage
|
|
52
|
+
- coverage report
|
|
53
|
+
- coverage xml
|
|
54
|
+
- coverage html
|
|
55
|
+
needs:
|
|
56
|
+
- Tests with docker compose
|
|
57
|
+
except: [main, tags]
|
|
58
|
+
artifacts:
|
|
59
|
+
paths:
|
|
60
|
+
- htmlcov/
|
|
61
|
+
when: always
|
|
62
|
+
reports:
|
|
63
|
+
coverage_report:
|
|
64
|
+
coverage_format: cobertura
|
|
65
|
+
path: coverage.xml
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 INRAE
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: teledetection
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Software development kit for the Geospatial Data Center of 'la Maison de la Teledetection'
|
|
5
|
+
Author-email: Rémi Cresson <remi.cresson@inrae.fr>, Pablo Boizeau <pablo.boizeau@ird.fr>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: setuptools>=61.2
|
|
17
|
+
Requires-Dist: click>=7.1
|
|
18
|
+
Requires-Dist: pydantic<3.0.0,>=1.7.3
|
|
19
|
+
Requires-Dist: pystac>=1.0.0
|
|
20
|
+
Requires-Dist: pystac-client>=0.2.0
|
|
21
|
+
Requires-Dist: requests>=2.25.1
|
|
22
|
+
Requires-Dist: packaging
|
|
23
|
+
Requires-Dist: qrcode
|
|
24
|
+
Requires-Dist: appdirs
|
|
25
|
+
Requires-Dist: pydantic_settings
|
|
26
|
+
Provides-Extra: test
|
|
27
|
+
Requires-Dist: pytest; extra == "test"
|
|
28
|
+
Requires-Dist: coverage; extra == "test"
|
|
29
|
+
Provides-Extra: upload
|
|
30
|
+
Requires-Dist: rich; extra == "upload"
|
|
31
|
+
Requires-Dist: rasterio; extra == "upload"
|
|
32
|
+
Requires-Dist: rio-cogeo; extra == "upload"
|
|
33
|
+
Requires-Dist: rio-stac; extra == "upload"
|
|
34
|
+
Dynamic: license-file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Teledetection
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="doc/logo.png" width="320px">
|
|
5
|
+
<br>
|
|
6
|
+
<a href="https://forgemia.inra.fr/cdos-pub/teledetection/-/releases">
|
|
7
|
+
<img src="https://forgemia.inra.fr/cdos-pub/teledetection/-/badges/release.svg">
|
|
8
|
+
</a>
|
|
9
|
+
<a href="https://forgemia.inra.fr/cdos-pub/teledetection/-/commits/main">
|
|
10
|
+
<img src="https://forgemia.inra.fr/cdos-pub/teledetection/badges/main/pipeline.svg">
|
|
11
|
+
</a>
|
|
12
|
+
<a href="LICENSE">
|
|
13
|
+
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg">
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://forgemia.inra.fr/cdos-pub/teledetection/-/commits/main">
|
|
16
|
+
<img src="https://forgemia.inra.fr/cdos-pub/teledetection/badges/main/coverage.svg">
|
|
17
|
+
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
**teledetection** enables to use the STAC based geospatial data infrastructure
|
|
21
|
+
of *la Maison de la Teledetection*.
|
|
22
|
+
|
|
23
|
+
For more information read the [documentation](https://cdos-pub.pages.mia.inra.fr/teledetection).
|
|
24
|
+
|
|
25
|
+
## Contact
|
|
26
|
+
|
|
27
|
+
remi cresson @ inrae
|
|
28
|
+
pablo boizeau @ ird
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Get access to push data
|
|
2
|
+
|
|
3
|
+
The *Maison de la Teledetection* STAC API is transactionnal: any user
|
|
4
|
+
can push STAC objects to the API. On the other end, the signing URLs
|
|
5
|
+
API allows to upload files to the servers.
|
|
6
|
+
|
|
7
|
+
To be able to push STAC objects and files, a policy must be defined for
|
|
8
|
+
the user to allow the operations on the `collections` (for STAC) and
|
|
9
|
+
`storages` (for files) resources, in
|
|
10
|
+
[this repository](https://forgemia.inra.fr/cdos-pub/admin/cdos-ops).
|
|
11
|
+
To request the required permissions, the user can perform a
|
|
12
|
+
[merge request](https://docs.gitlab.com/ee/user/project/merge_requests/)
|
|
13
|
+
, to modify the `policies.yaml` file of the repository.
|
|
14
|
+
|
|
15
|
+
## Example of `policies.yaml`
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
rules:
|
|
19
|
+
- user: user_name
|
|
20
|
+
collections:
|
|
21
|
+
- nom-collection-1
|
|
22
|
+
- nom-collection-2
|
|
23
|
+
storages:
|
|
24
|
+
- https://s3-data.meso.umontpellier.fr/bucket1/prefixe1
|
|
25
|
+
- https://s3-data.meso.umontpellier.fr/bucket1/prefixe2
|
|
26
|
+
- https://s3-data.meso.umontpellier.fr/bucket2
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Note that `collections` and `storages` are completely independent.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Additional resources
|
|
2
|
+
|
|
3
|
+
## API Documentation
|
|
4
|
+
|
|
5
|
+
- [*Maison de la Teledetection* STAC API](https://stacapi.stac.teledetection.fr/api.html)
|
|
6
|
+
- [*THEIA-MTD* STAC API](https://theia.stac.teledetection.fr/api.html)
|
|
7
|
+
- [*Maison de la Teledetection* URL signing API](https://s3-signing.stac.teledetection.fr/docs)
|
|
8
|
+
|
|
9
|
+
## STAC documentation
|
|
10
|
+
|
|
11
|
+
- [PySTAC documentation](https://pystac.readthedocs.io/en/stable/api/pystac.html)
|
|
12
|
+
- [PySTAC-Client documentation](https://pystac-client.readthedocs.io/en/stable/)
|
|
13
|
+
- More information about the [STAC specification](https://stacspec.org/en/about/stac-spec/)
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Advanced use
|
|
2
|
+
|
|
3
|
+
## Sign after the search
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
# See search described in previous sections
|
|
7
|
+
items = search.item_collection()
|
|
8
|
+
item = items.items[0]
|
|
9
|
+
item = teledetection.sign_inplace(item)
|
|
10
|
+
print(item.assets)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
!!! Hint
|
|
14
|
+
|
|
15
|
+
`item = teledetection.sign(item)` also works.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Get headers
|
|
19
|
+
|
|
20
|
+
For the developer it can be convenient just to grab headers (whatever the
|
|
21
|
+
authentication method is) to use them is various API endpoints.
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import teledetection as tld
|
|
25
|
+
|
|
26
|
+
headers = tld.get_headers()
|
|
27
|
+
requests.get(..., headers=headers)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Under the hood
|
|
32
|
+
|
|
33
|
+
The principle is to retrieve the signed URLs and use them to open remote
|
|
34
|
+
rasters in QGIS.
|
|
35
|
+
|
|
36
|
+
### Retrieve the signed URL
|
|
37
|
+
|
|
38
|
+
The following code does a STAC search and displays the assets URLs:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from pystac_client import Client
|
|
42
|
+
from teledetection import sign_inplace
|
|
43
|
+
|
|
44
|
+
api = Client.open(
|
|
45
|
+
'https://stacapi.stac.teledetection.fr',
|
|
46
|
+
modifier=sign_inplace
|
|
47
|
+
)
|
|
48
|
+
res = api.search(
|
|
49
|
+
bbox=[4, 42.99, 5, 44.05],
|
|
50
|
+
datetime=["2022-01-01", "2022-12-25"],
|
|
51
|
+
collections=["spot-6-7-drs"]
|
|
52
|
+
)
|
|
53
|
+
for item in res.items():
|
|
54
|
+
print(f"Links for {item.id}:")
|
|
55
|
+
print(item.assets['src_pan'].href)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Result has the following form: `https://minio-api-dinamis.apps.okd...?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=...&X-Amz-Date=...&X-Amz-Expires=28800&X-Amz-SignedHeaders=host&X-Amz-Signature=...`
|
|
59
|
+
|
|
60
|
+
### Bonus: Open COG files in QGIS
|
|
61
|
+
|
|
62
|
+
To open one COG in QGIS, follow these steps:
|
|
63
|
+
|
|
64
|
+
- Copy one link
|
|
65
|
+
- In QGIS: *Layer* > *Add layer* > *Add raster layer*
|
|
66
|
+
- In *Source type*, select *Protocol: HTTP(S), cloud, etc*
|
|
67
|
+
- Paste the copied link in the *url* field
|
|
68
|
+
|
|
69
|
+
You can then process the remote COGs as any raster with your favorite tool
|
|
70
|
+
from QGIS.
|
|
71
|
+
|
|
72
|
+
!!! Warning
|
|
73
|
+
|
|
74
|
+
QGIS must be at least **3.18 (Firenze)** to open remote COG files
|
|
75
|
+
|
|
76
|
+
!!! Hint
|
|
77
|
+
|
|
78
|
+
There is actually a simpler way to fetch our data using QGIS, check our [documentation](https://home-cdos.apps.okd.crocc.meso.umontpellier.fr/en/page/qgis/).
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
## Environment variables
|
|
83
|
+
|
|
84
|
+
- `TLD_TTL_MARGIN`:
|
|
85
|
+
Every signed URL has a TTL, returned by the signing URL API (`expiry`).
|
|
86
|
+
To prevent the expiry of one signed URL during a long process, a margin of
|
|
87
|
+
1800 seconds (30 minutes) is used by default. This duration can be changed
|
|
88
|
+
setting this environment variable to a number of seconds. When one given
|
|
89
|
+
URL has to be signed again, the cached URL will not be used when the
|
|
90
|
+
previous TTL minus the margin is negative. 30 minutes should be enough
|
|
91
|
+
for most processing, however feel free to increase this value to prevent
|
|
92
|
+
your long process crashing, if it has started with one URL with a short TTL.
|
|
93
|
+
|
|
94
|
+
- `TLD_URL_DURATION`:
|
|
95
|
+
Signed URLs have a default duration set by the signing API endpoint (in
|
|
96
|
+
general, a few hours). You can change the duration up to 6 days setting
|
|
97
|
+
this environment variable, in seconds.
|
|
98
|
+
|
|
99
|
+
- `TLD_DISABLE_AUTH`:
|
|
100
|
+
Use this environment variable to disable authentication mechanism.
|
|
101
|
+
|
|
102
|
+
- `TLD_CONFIG_DIR`:
|
|
103
|
+
The default config directory used to store authentication credentials (i.e.
|
|
104
|
+
jwt tokens and API key) is located in the user config folder (In linux:
|
|
105
|
+
`/home/user/.config/TLD_auth`). Set this environment variable to
|
|
106
|
+
set a different directory.
|
|
107
|
+
|
|
108
|
+
- `TLD_ACCESS_KEY` and `TLD_SECRET_KEY` can be used to
|
|
109
|
+
set your API key from the environment.
|
|
110
|
+
|
|
111
|
+
- `TLD_RETRY_TOTAL` and `TLD_RETRY_BACKOFF` can be set to
|
|
112
|
+
control the retry strategy of requests to the signing API endpoint.
|
|
113
|
+
|
|
114
|
+
- `TLD_SIGNING_ENDPOINT`: use this to change the signing endpoint.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Credentials
|
|
2
|
+
|
|
3
|
+
There is two ways of authenticating to the MTD's CDS Geospatial data
|
|
4
|
+
infrastructure:
|
|
5
|
+
|
|
6
|
+
- OAuth2
|
|
7
|
+
- API key
|
|
8
|
+
|
|
9
|
+
## OAuth2
|
|
10
|
+
|
|
11
|
+
The credentials are retrieved using the device code flow on the first call of
|
|
12
|
+
`teledetection.sign_inplace()`. Just follow the instructions, i.e. click on the
|
|
13
|
+
HTTP link, or scan the QR-code.
|
|
14
|
+
|
|
15
|
+
The credentials are valid for 5 days. Every time `teledetection.sign_inplace()`
|
|
16
|
+
is called, the credentials are renewed for another 5 days. After 5 days idle,
|
|
17
|
+
you will have to log in again.
|
|
18
|
+
If you want something more persistent, or that you can use on several
|
|
19
|
+
computers, you should use an API key.
|
|
20
|
+
|
|
21
|
+
## API key
|
|
22
|
+
|
|
23
|
+
API key allow to sign URLs without being authenticated with the single sign on.
|
|
24
|
+
Typically, you can use an API key on several machines without having to
|
|
25
|
+
authenticate each time you want to use the SDK.
|
|
26
|
+
The SDK can read the API key in two ways:
|
|
27
|
+
|
|
28
|
+
- From user settings file
|
|
29
|
+
- From environment variables
|
|
30
|
+
|
|
31
|
+
The command line interface (`teledetection`) enables to
|
|
32
|
+
manage API keys.
|
|
33
|
+
|
|
34
|
+
### From user settings file
|
|
35
|
+
|
|
36
|
+
Use `teledetection` to register an API key, that will be created and stored into
|
|
37
|
+
your local home directory.
|
|
38
|
+
|
|
39
|
+
```commandline
|
|
40
|
+
tld register
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Typically on linux the generated API key will be stored in
|
|
44
|
+
`/home/username/.config/teledetection_auth/.apikey`.
|
|
45
|
+
Optionally you can override the parent directory setting `TLD_SETTING_DIR`.
|
|
46
|
+
|
|
47
|
+
Just follow the instructions to log in a single time, then the API key can be used forever on your local computer.
|
|
48
|
+
You can duplicate the API key file on other computers.
|
|
49
|
+
|
|
50
|
+
You can delete the registered API key with:
|
|
51
|
+
|
|
52
|
+
```commandline
|
|
53
|
+
tld delete
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### From environment variables
|
|
57
|
+
|
|
58
|
+
You can create a new API key with:
|
|
59
|
+
|
|
60
|
+
```commandline
|
|
61
|
+
tld create
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
!!! Warning
|
|
65
|
+
|
|
66
|
+
Note that once created, you won't be able to retrieve the secret key
|
|
67
|
+
anymore.
|
|
68
|
+
|
|
69
|
+
You can then use the access and secret keys setting `TLD_ACCESS_KEY`
|
|
70
|
+
and `TLD_SECRET_KEY`.
|
|
71
|
+
|
|
72
|
+
### API key management
|
|
73
|
+
|
|
74
|
+
List all generated API keys:
|
|
75
|
+
|
|
76
|
+
```commandline
|
|
77
|
+
tld list
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Revoke a single API key:
|
|
81
|
+
|
|
82
|
+
```commandline
|
|
83
|
+
tld revoke
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Revoke all generated API keys:
|
|
87
|
+
|
|
88
|
+
```commandline
|
|
89
|
+
tld revoke-all
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Signed URLs expiry
|
|
93
|
+
|
|
94
|
+
The signed URLs for STAC objects assets are valid during 8 hours after
|
|
95
|
+
`teledetection.sign_inplace` is called.
|
|
96
|
+
|
|
97
|
+
!!! Info
|
|
98
|
+
|
|
99
|
+
`teledetection.sign_inplace()` can also be applied directly on a particular
|
|
100
|
+
`pystac.item`, `pystac.collection`, `pystac.asset` or any URL as `str`,
|
|
101
|
+
with the same outcome in term of expiry.
|
|
102
|
+
|
|
103
|
+
!!! Warning
|
|
104
|
+
|
|
105
|
+
Do no confuse credentials validity with images URL token validity.
|
|
106
|
+
Both have different lifecycle. To read how to ask for longer
|
|
107
|
+
URLs time-to-live, please read the API reference of
|
|
108
|
+
`teledetection.sign_inplace()`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Source codes of examples in [this section](#processing_examples.html)."""
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Basic example
|
|
2
|
+
|
|
3
|
+
The following example does a Stac search and returns usable Stac objects (Stac assets URLs are signed).
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from pystac_client import Client
|
|
7
|
+
from teledetection import sign_inplace
|
|
8
|
+
|
|
9
|
+
api = Client.open(
|
|
10
|
+
'https://stacapi.stac.teledetection.fr',
|
|
11
|
+
modifier=sign_inplace
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
res = api.search(
|
|
15
|
+
bbox=[4, 42.99, 5, 44.05],
|
|
16
|
+
datetime=["2022-01-01", "2022-12-25"],
|
|
17
|
+
collections=["spot-6-7-drs"]
|
|
18
|
+
)
|
|
19
|
+
items = search.item_collection()
|
|
20
|
+
print(f"{len(items)} items found")
|
|
21
|
+
item = items.items[0]
|
|
22
|
+
```
|
|
23
|
+
|