Skip to main content

example workflow

csbschema

csbschema defines a JSON Schema and validator (implemented in Pyhon) for IHO B-12 Crowdsourced Bathymetry metadata and data.

Installation

To install from PyPi, first create a virtual environment for your project, then:

pip install csbschema

Clone or download this repository, then run:

$ pip install .

Usage

Convention GeoJSON CSB 3.1

JSON files conforming to GeoJSON CSB 3.0.0 metadata can be validated using the 3.1.0-2023-03 schema (e.g., convention 'GeoJSON CSB 3.1'):

$ csbschema validate -f docs/IHO/b12_v3_1_0_example.json
CSB data file 'docs/IHO/b12_v3_1_0_example.json' successfully validated against schema '3.1.0-2023-03'.

Validating an invalid document will show where in the document errors were be found:

$ csbschema validate -f docs/IHO/b12_v3_1_0_example-invalid.json 
Validation of docs/IHO/b12_v3_1_0_example-invalid.json against schema 3.1.0-2023-03 failed due to the following errors: 
Path: /properties/trustedNode/convention, error: 'GeoJSON CSB 3.0' is not one of ['GeoJSON CSB 3.1']
Path: /features/1/properties, error: 'depth' is a required property
Path: /features/3/properties, error: 'time' is a required property
Path: /features/4/properties/time, error: '2016-03-03 18:41:49Z' does not match '^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)([.][0-9]+)?[Zz]$'
Path: /properties/platform/IDNumber, error: IDNumber IMO3699580 is not valid for IDType MMSI.
Path: /properties/platform/dataProcessed, error: dataProcessed flag is 'false', but 'processing' properties were found.
Path: /properties/platform/uniqueID, error: uniqueID: SEAID-45f5c322-10f2-4946-802e-d5992ad36727 does not match /properties/trustedNode/uniqueVesselID: SEAID-e8c469f8-df38-11e5-b86d-9a79f06e9478

Conventions GeoJSON CSB 3.0 and XYZ CSB 3.0

A schema for the provisional JSON encoding of B12 3.0.0 data and metadata (e.g., convention 'GeoJSON CSB 3.0') is available under the schema name '3.0.0-2023-03':

$ csbschema validate -f docs/NOAA/example_csb_geojson_file.geojson --version 3.0.0-2023-03

Similarly, a metadata-only schema (e.g., convention 'XYZ CSB 3.0') is available under the schema name 'XYZ-3.0.0-2023-03':

$ csbschema validate -f docs/NOAA/noaa_b12_v3_0_0_xyz_required.json --version XYZ-3.0.0-2023-03

The metadata-only 'XYZ schema' is meant to be used for JSON metadata supplied alongside CSB data in CSV or another format.

Convention GeoJSON CSB 3.2

A schema for a beta JSON encoding of B12 3.0.0 (e.g., convention 'GeoJSON CSB 3.2') is available under the schema name '3.2.0-BETA':

$ csbschema validate -f docs/IHO/b12_v3_2_0-BETA_example.json --version 3.2.0-BETA
CSB data file 'docs/IHO/b12_v3_2_0-BETA_example.json' successfully validated against schema '3.2.0-BETA'.

Run csbschema validate --help for more information about validating against different versions of the schema.

Testing

First, install test dependencies:

$ pip install -r requirements-test.txt

Then run unit tests:

$ pytest tests/unit/test_*.py

Run integration tests, which tests running the csbschema validate command line tool for many of the example CSB documents found in the csbschema repository:

$ bash tests/integration/validate_cmd.sh

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

csbschema-1.1.1.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

csbschema-1.1.1-py3-none-any.whl (49.4 kB view details)

Uploaded Python 3

File details

Details for the file csbschema-1.1.1.tar.gz.

File metadata

  • Download URL: csbschema-1.1.1.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for csbschema-1.1.1.tar.gz
Algorithm Hash digest
SHA256 388298ccc7d24cbcfbbccf212fcb3dc57d74d524cc940de15ccc38fbf2dcc78c
MD5 ab849518feac2405384f559bedf3cf46
BLAKE2b-256 994ef19f67991db9dab7ed670ebe841ee6e39d57af6c763f5499c426c1f7c3b7

See more details on using hashes here.

File details

Details for the file csbschema-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: csbschema-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 49.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for csbschema-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b11d2c1ce7ad98a0a454ba41bfd95b25d67da4282e0012cefa5b2d74fbf8d253
MD5 88c5b383fdb815fb5f8fd6c4ab10c814
BLAKE2b-256 d48e98938631e71dab815258994076f0c52af4781443c737d42ff6cbe34a146b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page