stac-validator 3.5.0__tar.gz → 3.7.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.
@@ -0,0 +1,541 @@
1
+ Metadata-Version: 2.1
2
+ Name: stac_validator
3
+ Version: 3.7.0
4
+ Summary: A package to validate STAC files
5
+ Home-page: https://github.com/stac-utils/stac-validator
6
+ Author: James Banting, Jonathan Healy
7
+ Author-email: jonathan.d.healy@gmail.com
8
+ License: Apache-2.0
9
+ Keywords: STAC validation raster
10
+ Classifier: Intended Audience :: Information Technology
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Topic :: Scientific/Engineering :: GIS
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown
17
+ Provides-Extra: dev
18
+ Provides-Extra: pydantic
19
+ License-File: LICENSE
20
+
21
+ # SpatioTemporal Asset Catalog Validator
22
+
23
+ <!-- markdownlint-disable MD033 MD041 -->
24
+
25
+ <p align="left">
26
+ <img src="https://raw.githubusercontent.com/stac-utils/stac-validator/main/assets/stac-validator.png" width=560>
27
+ </p>
28
+
29
+ [![Downloads](https://static.pepy.tech/badge/stac-validator?color=blue)](https://pepy.tech/project/stac-validator)
30
+ [![GitHub contributors](https://img.shields.io/github/contributors/stac-utils/stac-validator?color=blue)](https://github.com/stac-utils/stac-validator/graphs/contributors)
31
+ [![GitHub stars](https://img.shields.io/github/stars/stac-utils/stac-validator.svg?color=blue)](https://github.com/stac-utils/stac-validator/stargazers)
32
+ [![GitHub forks](https://img.shields.io/github/forks/stac-utils/stac-validator.svg?color=blue)](https://github.com/stac-utils/stac-validator/network/members)
33
+ [![PyPI version](https://img.shields.io/pypi/v/stac-validator.svg?color=blue)](https://pypi.org/project/stac-validator/)
34
+ [![STAC](https://img.shields.io/badge/STAC-1.1.0-blue.svg)](https://github.com/radiantearth/stac-spec/tree/v1.1.0)
35
+
36
+ ## Table of Contents
37
+
38
+ - [Overview](#overview)
39
+ - [Documentation](#documentation)
40
+ - [Requirements](#requirements)
41
+ - [Installation](#install)
42
+ - [Supported STAC Versions](#versions-supported)
43
+ - [Usage](#usage)
44
+ - [CLI](#cli)
45
+ - [Python](#python)
46
+ - [Examples](#additional-examples)
47
+ - [Core Validation](#--core)
48
+ - [Custom Schema](#--custom)
49
+ - [Extensions Validation](#--extensions)
50
+ - [Recursive Validation](#--recursive)
51
+ - [Item Collection Validation](#--item-collection)
52
+ - [Using Headers](#--header)
53
+ - [Schema Mapping](#--schema-map)
54
+ - [Pydantic Validation](#--pydantic)
55
+ - [Deployment](#deployment)
56
+ - [Docker](#docker)
57
+ - [AWS (CDK)](#aws-cdk)
58
+ - [Testing](#testing)
59
+ - [Related Projects](#related-projects)
60
+ - [Sponsors and Supporters](#sponsors-and-supporters)
61
+ - [Contributing](#contributing)
62
+ - [License](#license)
63
+
64
+ ## Overview
65
+
66
+ STAC Validator is a tool to validate [STAC (SpatioTemporal Asset Catalog)](https://github.com/radiantearth/stac-spec) json files against the official STAC specification. It provides both a command-line interface and a Python API for validating STAC objects.
67
+
68
+ ## Documentation
69
+
70
+ For detailed documentation, please visit our [GitHub Pages documentation site](https://stac-utils.github.io/stac-validator/).
71
+
72
+ ## Validate STAC json files against the [STAC spec](https://github.com/radiantearth/stac-spec).
73
+
74
+ ```bash
75
+ $ stac-validator https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/extended-item.json
76
+ ```
77
+
78
+ ```bash
79
+ [
80
+ {
81
+ "version": "1.0.0",
82
+ "path": "https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/extended-item.json",
83
+ "schema": [
84
+ "https://stac-extensions.github.io/eo/v1.0.0/schema.json",
85
+ "https://stac-extensions.github.io/projection/v1.0.0/schema.json",
86
+ "https://stac-extensions.github.io/scientific/v1.0.0/schema.json",
87
+ "https://stac-extensions.github.io/view/v1.0.0/schema.json",
88
+ "https://stac-extensions.github.io/remote-data/v1.0.0/schema.json",
89
+ "https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json"
90
+ ],
91
+ "valid_stac": true,
92
+ "asset_type": "ITEM",
93
+ "validation_method": "default"
94
+ }
95
+ ]
96
+ ```
97
+
98
+ ## Requirements
99
+
100
+ - Python 3.8+
101
+ - Requests
102
+ - Click
103
+ - Jsonschema
104
+
105
+ ## Related Projects
106
+
107
+ Note: Stac-validator is also used in stac-check which adds linting messages based on the official STAC best practices document.
108
+ https://github.com/stac-utils/stac-check
109
+
110
+ ## Install
111
+
112
+ ### Installation from PyPi
113
+
114
+ ```bash
115
+ $ pip install stac-validator
116
+ ```
117
+
118
+ ### Installation from Repo
119
+
120
+ ```bash
121
+ $ pip install .
122
+ ```
123
+
124
+ or for local development
125
+
126
+ ```bash
127
+ $ pip install -e '.[dev]'
128
+ ```
129
+
130
+ The [Makefile](./Makefile) has convenience commands if Make is installed.
131
+
132
+ ```bash
133
+ $ make help
134
+ ```
135
+
136
+ ## Versions supported
137
+
138
+ | STAC |
139
+ | ------------ |
140
+ | 0.8.0 |
141
+ | 0.8.1 |
142
+ | 0.9.0 |
143
+ | 1.0.0-beta.1 |
144
+ | 1.0.0-beta.2 |
145
+ | 1.0.0-rc.1 |
146
+ | 1.0.0-rc.2 |
147
+ | 1.0.0-rc.3 |
148
+ | 1.0.0-rc.4 |
149
+ | 1.0.0 |
150
+ | 1.1.0-beta.1 |
151
+ | 1.1.0 |
152
+
153
+ ## Usage
154
+
155
+ ### CLI
156
+
157
+ **Basic Usage**
158
+
159
+ ```bash
160
+ $ stac-validator --help
161
+ ```
162
+
163
+ ```bash
164
+ Usage: stac-validator [OPTIONS] STAC_FILE
165
+
166
+ Options:
167
+ --core Validate core stac object only without
168
+ extensions.
169
+ --extensions Validate extensions only.
170
+ --links Additionally validate links. Only works with
171
+ default mode.
172
+ --assets Additionally validate assets. Only works
173
+ with default mode.
174
+ -c, --custom TEXT Validate against a custom schema (local
175
+ filepath or remote schema).
176
+ -s, --schema-map <TEXT TEXT>...
177
+ Schema path to replaced by (local) schema
178
+ path during validation. Can be used multiple
179
+ times.
180
+ -r, --recursive Recursively validate all related stac
181
+ objects.
182
+ -m, --max-depth INTEGER Maximum depth to traverse when recursing.
183
+ Omit this argument to get full recursion.
184
+ Ignored if `recursive == False`.
185
+ --collections Validate /collections response.
186
+ --item-collection Validate item collection response. Can be
187
+ combined with --pages. Defaults to one page.
188
+ --no-assets-urls Disables the opening of href links when
189
+ validating assets (enabled by default).
190
+ --header <TEXT TEXT>... HTTP header to include in the requests. Can
191
+ be used multiple times.
192
+ -p, --pages INTEGER Maximum number of pages to validate via
193
+ --item-collection. Defaults to one page.
194
+ -v, --verbose Enables verbose output for recursive mode.
195
+ --no_output Do not print output to console.
196
+ --log_file TEXT Save full recursive output to log file
197
+ (local filepath).
198
+ --pydantic Validate using stac-pydantic models for enhanced
199
+ type checking and validation.
200
+ --help Show this message and exit.
201
+ ```
202
+
203
+ ### Python
204
+
205
+ **Remote source**
206
+
207
+ ```python
208
+ from stac_validator import stac_validator
209
+
210
+ stac = stac_validator.StacValidate("https://raw.githubusercontent.com/stac-utils/pystac/main/tests/data-files/examples/0.9.0/collection-spec/examples/landsat-collection.json")
211
+ stac.run()
212
+ print(stac.message)
213
+ ```
214
+ ```python
215
+ [
216
+ {
217
+ "version": "0.9.0",
218
+ "path": "https://raw.githubusercontent.com/stac-utils/pystac/main/tests/data-files/examples/0.9.0/collection-spec/examples/landsat-collection.json",
219
+ "schema": [
220
+ "https://cdn.staclint.com/v0.9.0/collection.json"
221
+ ],
222
+ "valid_stac": true,
223
+ "asset_type": "COLLECTION",
224
+ "validation_method": "default"
225
+ }
226
+ ]
227
+ ```
228
+
229
+ **Local file**
230
+
231
+ ```python
232
+ from stac_validator import stac_validator
233
+
234
+ stac = stac_validator.StacValidate("tests/test_data/1beta1/sentinel2.json", extensions=True)
235
+ stac.run()
236
+ print(stac.message)
237
+ ```
238
+ ```python
239
+ [
240
+ {
241
+ "version": "1.0.0-beta.1",
242
+ "path": "tests/test_data/1beta1/sentinel2.json",
243
+ "schema": [
244
+ "https://cdn.staclint.com/v1.0.0-beta.1/collection.json"
245
+ ],
246
+ "valid_stac": true,
247
+ "asset_type": "COLLECTION",
248
+ "validation_method": "extensions"
249
+ }
250
+ ]
251
+ ```
252
+
253
+ **Dictionary**
254
+
255
+ ```python
256
+ from stac_validator import stac_validator
257
+
258
+ stac = stac_validator.StacValidate()
259
+ stac.validate_dict(dictionary)
260
+ print(stac.message)
261
+ ```
262
+
263
+ **Item Collection**
264
+
265
+ ```python
266
+ from stac_validator import stac_validator
267
+
268
+ stac = stac_validator.StacValidate()
269
+ stac.validate_item_collection_dict(item_collection_dict)
270
+ print(stac.message)
271
+ ```
272
+
273
+ ## Deployment
274
+
275
+ ### Docker
276
+
277
+ The validator can run using docker containers.
278
+
279
+ ```bash
280
+ $ docker build -t stac-validator .
281
+ $ docker run stac-validator https://raw.githubusercontent.com/stac-extensions/projection/main/examples/item.json
282
+ ```
283
+
284
+ ```bash
285
+ [
286
+ {
287
+ "version": "1.0.0",
288
+ "path": "https://raw.githubusercontent.com/stac-extensions/projection/main/examples/item.json",
289
+ "schema": [
290
+ "https://stac-extensions.github.io/projection/v1.0.0/schema.json",
291
+ "https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json"
292
+ ],
293
+ "valid_stac": true,
294
+ "asset_type": "ITEM",
295
+ "validation_method": "default"
296
+ }
297
+ ]
298
+ ```
299
+
300
+ ### AWS (CDK)
301
+
302
+ An example [AWS CDK](https://aws.amazon.com/cdk/) deployment is available in [cdk-deployment](./cdk-deployment/README.md)
303
+
304
+ ```bash
305
+ $ cd cdk-deployment
306
+ $ cdk diff
307
+ ```
308
+
309
+ ## Testing
310
+
311
+ ```bash
312
+ $ make test
313
+ # or
314
+ $ pytest -v
315
+ ```
316
+
317
+ See the [tests](./tests/test_stac_validator.py) files for examples on different usages.
318
+
319
+ ## Additional Examples
320
+
321
+ ### --core
322
+
323
+ ```bash
324
+ $ stac-validator https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/extended-item.json --core
325
+ ```
326
+
327
+ ```bash
328
+ [
329
+ {
330
+ "version": "1.0.0",
331
+ "path": "https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/extended-item.json",
332
+ "schema": [
333
+ "https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json"
334
+ ],
335
+ "valid_stac": true,
336
+ "asset_type": "ITEM",
337
+ "validation_method": "core"
338
+ }
339
+ ]
340
+ ```
341
+
342
+ ### --custom
343
+
344
+ ```bash
345
+ $ stac-validator https://radarstac.s3.amazonaws.com/stac/catalog.json --custom https://cdn.staclint.com/v0.7.0/catalog.json
346
+ ```
347
+
348
+ ```bash
349
+ [
350
+ {
351
+ "version": "0.7.0",
352
+ "path": "https://radarstac.s3.amazonaws.com/stac/catalog.json",
353
+ "schema": [
354
+ "https://cdn.staclint.com/v0.7.0/catalog.json"
355
+ ],
356
+ "asset_type": "CATALOG",
357
+ "validation_method": "custom",
358
+ "valid_stac": true
359
+ }
360
+ ]
361
+ ```
362
+
363
+ ### --extensions
364
+
365
+ ```bash
366
+ $ stac-validator https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/extended-item.json --extensions
367
+ ```
368
+
369
+ ```bash
370
+ [
371
+ {
372
+ "version": "1.0.0",
373
+ "path": "https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/extended-item.json",
374
+ "schema": [
375
+ "https://stac-extensions.github.io/eo/v1.0.0/schema.json",
376
+ "https://stac-extensions.github.io/projection/v1.0.0/schema.json",
377
+ "https://stac-extensions.github.io/scientific/v1.0.0/schema.json",
378
+ "https://stac-extensions.github.io/view/v1.0.0/schema.json",
379
+ "https://stac-extensions.github.io/remote-data/v1.0.0/schema.json"
380
+ ],
381
+ "valid_stac": true,
382
+ "asset_type": "ITEM",
383
+ "validation_method": "extensions"
384
+ }
385
+ ]
386
+ ```
387
+
388
+ ### --recursive
389
+
390
+ ```bash
391
+ $ stac-validator https://spot-canada-ortho.s3.amazonaws.com/catalog.json --recursive --max-depth 1 --verbose
392
+ ```
393
+
394
+ ```bash
395
+ [
396
+ {
397
+ "version": "0.8.1",
398
+ "path": "https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot4_orthoimages/collection.json",
399
+ "schema": "https://cdn.staclint.com/v0.8.1/collection.json",
400
+ "asset_type": "COLLECTION",
401
+ "validation_method": "recursive",
402
+ "valid_stac": true
403
+ },
404
+ {
405
+ "version": "0.8.1",
406
+ "path": "https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/collection.json",
407
+ "schema": "https://cdn.staclint.com/v0.8.1/collection.json",
408
+ "asset_type": "COLLECTION",
409
+ "validation_method": "recursive",
410
+ "valid_stac": true
411
+ },
412
+ {
413
+ "version": "0.8.1",
414
+ "path": "https://spot-canada-ortho.s3.amazonaws.com/catalog.json",
415
+ "schema": "https://cdn.staclint.com/v0.8.1/catalog.json",
416
+ "asset_type": "CATALOG",
417
+ "validation_method": "recursive",
418
+ "valid_stac": true
419
+ }
420
+ ]
421
+ ```
422
+
423
+ ### --item-collection
424
+
425
+ ```bash
426
+ $ stac-validator https://earth-search.aws.element84.com/v0/collections/sentinel-s2-l2a/items --item-collection --pages 2
427
+ ```
428
+
429
+ ### --header
430
+
431
+ ```bash
432
+ $ stac-validator https://stac-catalog.eu/collections/sentinel-s2-l2a/items --header x-api-key $MY_API_KEY --header foo bar
433
+ ```
434
+
435
+ ### --schema-map
436
+
437
+ Schema map allows stac-validator to replace a schema in a STAC json by a schema from another URL or local schema file.
438
+ This is especially useful when developing a schema and testing validation against your local copy of the schema.
439
+
440
+ ```bash
441
+ $ stac-validator https://raw.githubusercontent.com/radiantearth/stac-spec/v1.0.0/examples/extended-item.json --extensions --schema-map https://stac-extensions.github.io/projection/v1.0.0/schema.json "tests/test_data/schema/v1.0.0/projection.json"
442
+ ```
443
+
444
+ ```bash
445
+ [
446
+ {
447
+ "version": "1.0.0",
448
+ "path": "https://raw.githubusercontent.com/radiantearth/stac-spec/v1.0.0/examples/extended-item.json",
449
+ "schema": [
450
+ "https://stac-extensions.github.io/eo/v1.0.0/schema.json",
451
+ "tests/test_data/schema/v1.0.0/projection.json",
452
+ "https://stac-extensions.github.io/scientific/v1.0.0/schema.json",
453
+ "https://stac-extensions.github.io/view/v1.0.0/schema.json",
454
+ "https://stac-extensions.github.io/remote-data/v1.0.0/schema.json"
455
+ ],
456
+ "valid_stac": true,
457
+ "asset_type": "ITEM",
458
+ "validation_method": "extensions"
459
+ }
460
+ ]
461
+ ```
462
+
463
+ This option is also capable of replacing URLs to subschemas:
464
+
465
+ ```bash
466
+ $ stac-validator tests/test_data/v100/extended-item-local.json --custom tests/test_data/schema/v1.0.0/item_with_unreachable_url.json --schema-map https://geojson-wrong-url.org/schema/Feature.json https://geojson.org/schema/Feature.json --schema-map https://geojson-wrong-url.org/schema/Geometry.json https://geojson.org/schema/Geometry.json
467
+ ```
468
+
469
+ ```bash
470
+ [
471
+ {
472
+ "version": "1.0.0",
473
+ "path": "tests/test_data/v100/extended-item-local.json",
474
+ "schema": [
475
+ "tests/test_data/schema/v1.0.0/item_with_unreachable_url.json"
476
+ ],
477
+ "valid_stac": true,
478
+ "asset_type": "ITEM",
479
+ "validation_method": "custom"
480
+ }
481
+ ]
482
+ ```
483
+
484
+ ### --pydantic
485
+
486
+ The `--pydantic` option provides enhanced validation using stac-pydantic models, which offer stronger type checking and more detailed error messages. To use this feature, you need to install the optional dependency:
487
+
488
+ ```bash
489
+ $ pip install stac-validator[pydantic]
490
+ ```
491
+
492
+ Then you can validate your STAC objects using Pydantic models:
493
+
494
+ ```bash
495
+ $ stac-validator https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/extended-item.json --pydantic
496
+ ```
497
+
498
+ ```bash
499
+ [
500
+ {
501
+ "version": "1.0.0",
502
+ "path": "https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/extended-item.json",
503
+ "schema": [
504
+ "stac-pydantic Item model"
505
+ ],
506
+ "valid_stac": true,
507
+ "asset_type": "ITEM",
508
+ "validation_method": "pydantic",
509
+ "extension_schemas": [
510
+ "https://stac-extensions.github.io/eo/v1.0.0/schema.json",
511
+ "https://stac-extensions.github.io/projection/v1.0.0/schema.json",
512
+ "https://stac-extensions.github.io/scientific/v1.0.0/schema.json",
513
+ "https://stac-extensions.github.io/view/v1.0.0/schema.json",
514
+ "https://stac-extensions.github.io/remote-data/v1.0.0/schema.json"
515
+ ],
516
+ "model_validation": "passed"
517
+ }
518
+ ]
519
+ ```
520
+
521
+ ## Sponsors and Supporters
522
+
523
+ The following organizations have contributed time and/or funding to support the development of this project:
524
+ - [Healy Hyperspatial](https://healy-hyperspatial.github.io/)
525
+ - [Radiant Earth Foundation](https://radiant.earth/)
526
+ - [Sparkgeo](https://sparkgeo.com/)
527
+
528
+ <p align="left">
529
+ <a href="https://healy-hyperspatial.github.io/"><img src="https://raw.githubusercontent.com/stac-utils/stac-fastapi-elasticsearch-opensearch/refs/heads/main/assets/hh-logo-blue.png" alt="Healy Hyperspatial" height="100" hspace="20"></a>
530
+ <a href="https://radiant.earth/"><img src="assets/radiant-earth.webp" alt="Radiant Earth Foundation" height="100" hspace="20"></a>
531
+ <a href="https://sparkgeo.com/"><img src="assets/sparkgeo_logo.jpeg" alt="Sparkgeo" height="100" hspace="20"></a>
532
+ </p>
533
+
534
+
535
+ ## Contributing
536
+
537
+ Contributions are welcome! Please feel free to submit a Pull Request.
538
+
539
+ ## License
540
+
541
+ This project is licensed under the Apache License 2.0.