geodetic-osdudb

Builds an enriched proj.db from an OSDU coordinate reference catalogue. No credentials and no network are involved. See Custom database from OSDU for the workflow.

Build a PROJ database enriched with the CRSs and transformations published in an OSDU coordinate reference catalogue.

usage: geodetic-osdudb [-h] [-v]
                       {build,download,validate,inspect,references,config} ...

Positional Arguments

command

Possible choices: build, download, validate, inspect, references, config

Named Arguments

-v, --verbose

log every imported object

Default: False

Sub-commands

build

build an enriched proj.db

geodetic-osdudb build [-h] [--official] [--config CONFIG] [--output OUTPUT]
                      [--authority AUTHORITIES] [--append] [--replace]
                      [--overwrite-rows] [--skip-validation]
                      [--no-osdu-id-aliases] [--no-persistable-references]
                      [--dry-run]
                      [catalog]

Positional Arguments

catalog

the OSDU manifest to read, for example CRS_CT.json

Named Arguments

--official

build the verified official catalogue included with this release

Default: False

--config

TOML file with an [osdudb] table

--output

path of the database to write

--authority

code space to import; repeatable. Defaults to OSDU. Add EPSG to also import the catalogue’s EPSG objects that this proj.db’s EPSG dataset does not yet define.

--append

add to the database already at –output instead of rebuilding it from the base proj.db, so this build extends what another source already wrote there

Default: False

--replace

discard an existing –output database built by other authorities; without this a build that would drop another source’s import is refused

Default: False

--overwrite-rows

replace a colliding row of this build’s own authorities instead of aborting, so this catalogue’s definitions win; each one replaced is listed in the build summary. Another authority’s rows are still never touched

Default: False

--skip-validation

write the database without checking that PROJ can read it back

Default: False

--no-osdu-id-aliases

record OSDU record ids only in the identifier table, not also as PROJ aliases; PROJ matches aliases approximately

Default: False

--no-persistable-references

do not record the PersistableReference each catalogue record publishes

Default: False

--dry-run

run the whole build and report what it would write, then discard it; nothing is left on disk

Default: False

download

Download the CRS_CT.json catalogue OSDU publishes in its Data Definitions repository, verify its SHA-256, and replace the copy committed in this repository with it, recording where it came from beside it. Review and commit the change. Prints what was downloaded as JSON.

geodetic-osdudb download [-h] [--output OUTPUT] [--ref REF]
                         [--timeout TIMEOUT]

Named Arguments

--output

where to write it; catalogs/osdu/CRS_CT_osdu_official_crs_catalog.json by default

Default: catalogs/osdu/CRS_CT_osdu_official_crs_catalog.json

--ref

the revision to fetch; master, the newest, by default

Default: 'master'

--timeout

seconds to wait for the server; 120 by default

Default: 120.0

validate

validate an existing proj.db

geodetic-osdudb validate [-h] --authority AUTHORITIES database

Positional Arguments

database

Named Arguments

--authority

authority to check; repeatable

inspect

summarise what a built database contains

geodetic-osdudb inspect [-h] database

Positional Arguments

database

references

Write the PersistableReference strings the catalogue publishes, as a database built from it recorded them, with the record id and the object each is for. Name objects to look them up, or name none to export every one. An object with no reference is written with a null reference and the reason.

geodetic-osdudb references [-h] [--format {json,jsonl,csv}] [--pretty]
                           [--pretty-wkt] [--entity {crs,operation}]
                           [--kind {LBC,EBC,ST,CT,USO,UAD}]
                           [--authority AUTHORITIES] [--active-only]
                           [--output OUTPUT]
                           database [VALUE ...]

Positional Arguments

database
VALUE

an OSDU record id, with or without its partition, or AUTH:CODE; every recorded reference when none is given

Named Arguments

--format

Possible choices: json, jsonl, csv

output format; json by default

Default: 'json'

--pretty

json only: give each reference as an indented object, not a string

Default: False

--pretty-wkt

json only: also lay each embedded ESRI WKT out over indented lines; the output is then for reading and is not JSON

Default: False

--entity

Possible choices: crs, operation

only CRSs, or only coordinate operations

--kind

Possible choices: LBC, EBC, ST, CT, USO, UAD

only references of this kind; repeatable. Not with VALUE

--authority

only objects of this authority; repeatable. Not with VALUE

--active-only

leave out records the catalogue marks inactive. Not with VALUE

Default: False

--output

file to write; standard output by default

config

show the resolved settings and where they came from

geodetic-osdudb config [-h] [--config CONFIG] [catalog]

Positional Arguments

catalog

Named Arguments

--config

TOML file with an [osdudb] table

Example configuration

geodetic-osdudb.example.toml, from the repository root. The file is optional: the catalogue path alone is enough to build, or use build --official for the catalogue included in the installed package.

# Settings for `geodetic-osdudb`.
#
# Copy this file to `geodetic-osdudb.toml` and edit the values. It is picked up
# automatically from the working directory; use --config to point elsewhere.
#
# Every setting here has a default, so this file is optional: a build can be run
# against nothing but the catalogue path,
#
#     geodetic-osdudb build CRS_CT.json
#
# There is nothing secret to configure. An OSDU catalogue is a file, so a build
# needs no credentials and no network.
#
# Precedence, highest first: command line options, environment variables, this
# file, built-in defaults. A misspelled setting is an error rather than being
# ignored, so a typo cannot silently leave a setting unapplied.

[osdudb]

# --- What to read -----------------------------------------------------------

# The OSDU manifest to read: a JSON document whose ReferenceData array holds
# reference-data--CoordinateReferenceSystem and
# reference-data--CoordinateTransformation records. A path given on the command
# line wins over this, and GEODETIC_ENGINE_OSDU_CATALOG wins over the file.
#
# local/ is gitignored, so a catalogue kept there cannot be committed by
# accident; the repository root is not, and a manifest is both large and
# frequently internal to whoever published it. Keep it out of build/ as well:
# that directory holds build output and is expected to be disposable.
catalog = "local/osdu/CRS_CT.json"

# Where the enriched database is written. The official proj.db is copied, never
# modified in place. Defaults to "build/proj.db".
# output_db = "build/proj.db"

# --- Which objects to import ------------------------------------------------

# Code spaces whose objects are imported, matched against each record's
# CodeSpace field. Only rows belonging to these may be written to the database;
# an attempt to write a row belonging to any other aborts the build.
#
# "OSDU" is the code space OSDU uses for the objects it defines itself, which in
# practice means the bound CRSs that pair an EPSG CRS with one named
# transformation to WGS 84.
#
# Adding "EPSG" also imports the catalogue's EPSG records. Only those the base
# proj.db does not already define are written, so this is how a catalogue newer
# than the EPSG dataset PROJ ships with fills the gap. Objects PROJ already
# defines are never rewritten.
# authorities = ["OSDU"]

# Import records flagged with InactiveIndicator, marked deprecated in the
# database so a caller gets "this code is deprecated" rather than "unknown
# code". OSDU records no replacement for an inactive record, so a deprecated
# object cannot be linked to whatever superseded it.
# include_deprecated = true

# Naming systems whose NameAlias entries are imported, taken from the segment
# after "AliasNameType:" in each alias's AliasNameTypeID. Defaults to the
# authorities above; "*" imports every naming system.
# naming_systems = ["*"]

# EPSG coordinate operation methods this PROJ build cannot evaluate. Objects
# using them are skipped and listed in the report rather than written as rows
# PROJ would fail on.
# unsupported_method_codes = [1044, 1108]

# --- OSDU record ids --------------------------------------------------------

# Every record's id, such as
# opendes:reference-data--CoordinateReferenceSystem:Projected:EPSG::23031, is
# recorded against the object it names, without its data partition, so it
# resolves wherever an authority code does. This package looks ids up exactly
# in its own table. With this on, each id is also written as a PROJ alias
# (source OSDU_ID), so tools reading proj.db through PROJ directly find it too.
# PROJ matches aliases approximately, so such a tool can resolve a mistyped id
# to a different CRS. Turn this off if other software reads the database.
# osdu_id_aliases = true

# Every record's PersistableReference is recorded verbatim against the record's
# id, including for the EPSG objects the base proj.db already defines, so the
# exact string the catalogue publishes can be looked up and exported for any
# object an id names (geodetic-osdudb references). A record that states none,
# or one that cannot be read, is listed in the build report and never fails the
# build. Adds about one and a half kilobytes per record. Turn this off to leave
# them out.
# osdu_persistable_references = true

# --- Operation selection ----------------------------------------------------

# How the imported operations enter PROJ's choice of transformation. This
# changes which operation is applied to a coordinate, so it is stated
# explicitly.
#
#   custom_first  Imported operations are preferred for CRS pairs involving an
#                 imported authority, and are appended to PROJ's shipped rules
#                 for other pairs so they become candidates without displacing
#                 EPSG's established ordering.
#   custom_only   Imported operations are preferred for pairs involving an
#                 imported authority. Selection between other authorities is
#                 untouched.
#   none          No preference rules are written. Imported operations are only
#                 found when one of the imported CRSs is named directly.
# authority_preference = "custom_first"

# Authorities listed after the imported ones in each generated rule.
# fallback_authorities = ["PROJ", "EPSG"]

# --- Combining sources ------------------------------------------------------

# Add to the database already at `output_db` instead of starting from a fresh
# copy of the official proj.db, so this catalogue extends one another source (a
# Georepository register, say) already wrote there. Has no effect when the
# output does not exist yet, so the first build of a chain still starts from
# the base. Off by default: a build that silently added to whatever happened to
# be at the output path could not be reproduced from its configuration alone.
# append = false

# Replace a row this build collides with instead of aborting. Only reaches the
# authorities configured above: the per-row authority guard runs first, and
# every object table is keyed on (auth_name, code), so a replacement can never
# land on an EPSG or PROJ definition. Off by default, so a collision is a
# reported failure rather than a definition that changed underneath whoever was
# already using it.
# overwrite_rows = false

# --- Advanced ---------------------------------------------------------------

# The official proj.db to start from. Defaults to the one belonging to the
# installed PROJ, which is what pyproj reads.
# base_proj_db = "/usr/local/share/proj/proj.db"

# Catalogue version, recorded verbatim in the build report so a database can be
# traced back to the manifest it was built from.
# catalog_version = "2024-06"