Skip to main content

KOF Parser

security: bandit security: safety code style Checked with mypy python

Python package for parsing and generating KOF files.

References:

NORWEGIAN GEOTECHNICAL SOCIETY

Latest releases see CHANGES.md

Installation (end user)

pip install kof-parser

Basic usage

Read a kof file

from kof_parser import KOFParser

parser = KOFParser()

# ETRS89/NTM10:
srid = 5110

locations = parser.parse("tests/data/test.kof", result_srid=srid, file_srid=srid)

for location in locations:
    print(location)

# Output:
# name='SMPLOC1' methods=[] point_easting=112892.81 point_northing=1217083.64 point_z=1.0 srid=5110
# name='SMPLOC2' methods=['TOT'] point_easting=112893.15 point_northing=1217079.46 point_z=2.0 srid=5110
# name='SMPLOC3' methods=['CPT'] point_easting=112891.88 point_northing=1217073.01 point_z=0.0 srid=5110
# name='SMPLOC4' methods=['RP'] point_easting=112891.9 point_northing=1217067.54 point_z=0.0 srid=5110
# name='SMPLOC5' methods=['SA'] point_easting=112902.92 point_northing=1217074.73 point_z=0.0 srid=5110
# name='SMPLOC6' methods=['PZ'] point_easting=112901.11 point_northing=1217069.56 point_z=0.0 srid=5110
# name='SMPLOC7' methods=['PZ'] point_easting=1217069.56 point_northing=112901.11 point_z=0.0 srid=5110

Write a kof file

To write a KOF file you need to build up a model of locations and methods.

from kof_parser import KOFWriter
from kof_parser import Location

kof_writer = KOFWriter()

srid = 5110
locations = [
    Location(name="SMPLOC1", point_easting=112892.81, point_northing=1217083.64, point_z=1.0),
    Location(name="SMPLOC2", point_easting=112893.15, point_northing=1217079.46, point_z=2.0, methods=["TOT"]),
    Location(name="SMPLOC3", point_easting=112891.88, point_northing=1217073.01, point_z=0.0, methods=["CPT"]),
]

kof_string = kof_writer.writeKOF(project_id="project_id", project_name="cool-name", locations=locations, srid=srid)

print(kof_string)
# Output:
# 00 KOF Export from NGI's KOF parser
# 00 Project: project_id. Name: cool-name
# 00 Spatial Reference ID (SRID): 5110
# 00 Export date (UTC): 2022-08-22 13:49:44.394607
# 00 Oppdrag      Dato     Ver K.sys   Komm $21100000000 Observer
# 01 cool-name    22082022   1     210      $11100000000
# 05 SMPLOC1             1217083.640  112892.810  1.000
# 05 SMPLOC2    2418     1217079.460  112893.150  2.000
# 05 SMPLOC3    2407     1217073.010  112891.880  0.000

Getting Started developing

Software dependencies

Before you start, install:

Clone this repository

Use git to clone this repository.

Install

There are several combinations of how to set up a local development environment.

We use uv for dependency management. See the uv docs if needed.

Then, from the project root folder run:

uv sync --dev

This will create a virtual environment (by default in .venv) and install all dependencies including dev tools.

Build and Test

Run tests in the project root folder:

uv run pytest

Build the package wheel:

uv build

Contribute

Please start by adding an issue before submitting any pull requests.

Metadata

Release files for kof-parser 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kof-parser 0.1.5
File Size Uploaded Provenance Actions
kof_parser-0.1.5.tar.gz 117.5 kB Without provenance Details for kof_parser-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kof-parser 0.1.5
File Interpreter ABI Platform Actions
kof_parser-0.1.5-py3-none-any.whl Python 3 none any Details for kof_parser-0.1.5-py3-none-any.whl

Total release size: 133.1 kB

Release files / kof_parser-0.1.5.tar.gz

Download URL kof_parser-0.1.5.tar.gz
Size 117.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a509247fe8641a27d88b3c5d1ad7e90037b153c7153406a7492c641862d7593d
BLAKE2b-256 checksum
How to use checksums
f1875967359c093c00e4114be0244248ac9712cd48b1dc0ed999f7c27ee29646
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / kof_parser-0.1.5-py3-none-any.whl

Download URL kof_parser-0.1.5-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e18113d1d70263e1964e039bde996fa7fa5f1fe626dc451e7de111c309a50d93
BLAKE2b-256 checksum
How to use checksums
d54742d998617b26404d6a52f3695662f3d755b8b634d3fe8c88212da76da49d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for kof-parser 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page