Skip to main content

Flatten dev.sensorthings ATProto repo (CAR) exports into tidy, geo-referenced tables.

Project description

atproto-sensorthings

Flatten a dev.sensorthings ATProto repo export into tidy, geo-referenced tables for analysis.

Sensor networks on sensorthings.dev publish their observations to an ATProto repository. You can download that repository as a single CAR file (from sensorthings.dev/yourdata, or via com.atproto.sync.getRepo). This package turns that CAR into three tables:

Table One row per Geometry
stations Thing (station) station point
datastreams Datastream station point
observations reading (long / tidy) station point, or the observed position for a GPS fix

Everything is derived from the CAR: no network access, no repo checkout, and the lexicons are not needed at runtime.

Install

The base install (parsing, the summary, and CSV output) depends only on atproto and click. Install as a command-line tool:

uv tool install atproto-sensorthings         # or: pipx install atproto-sensorthings

or add it to a project as a library:

uv add atproto-sensorthings                  # or: pip install atproto-sensorthings

GeoDataFrame and GeoJSON output need the geo extra (geopandas / shapely / pandas); GeoParquet also needs parquet:

uv add "atproto-sensorthings[geo]"           # or: pip install "atproto-sensorthings[geo]"
uv add "atproto-sensorthings[geo,parquet]"   # or: pip install "atproto-sensorthings[geo,parquet]"

Command line

# record counts and reading time span
atproto-sensorthings summary export.car

# write stations.csv, datastreams.csv, observations.csv to ./sensorthings_export
atproto-sensorthings flatten export.car

# GeoJSON (needs the geo extra); one layer at a time is also supported
atproto-sensorthings flatten export.car --format geojson --out export
atproto-sensorthings flatten export.car --format geoparquet --layer observations

CSV rows carry longitude / latitude columns, so they load as points in any GIS without the geo extra.

Library

import atproto_sensorthings as ast

repo = ast.read_car("export.car")

# pure core: plain dicts, streamed; no geopandas required
for row in ast.observation_rows(repo):
    ...

# with the geo extra: GeoDataFrames (imported lazily on first use)
stations = ast.stations_gdf(repo)        # 1 row / station
observations = ast.observations_gdf(repo)  # 1 row / reading, sorted, typed

Data notes

  • Coordinates are decoded from the lexicon's integer latE7 / lonE7 (degrees times 1e7) to WGS84 degrees; altitude from altMm to metres.
  • Numeric results are scaled integers: the real value is value * 10**-resultScaleFactor, applied automatically. In the observations table, value holds the decoded native result (float, string, boolean or list) and value_num is a nullable float for the numeric and boolean cases.
  • Result types covered: numeric, category, boolean, array, geoPoint.
  • Record types covered: observationBatch, observation and multiObservation, so every network's export flattens the same way.
  • The whole export is read into memory; for the largest agency repositories prefer GeoParquet output over GeoJSON.

Licence

MIT. See LICENSE.

Project details


Download files

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

Source Distribution

atproto_sensorthings-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

atproto_sensorthings-0.1.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file atproto_sensorthings-0.1.0.tar.gz.

File metadata

  • Download URL: atproto_sensorthings-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for atproto_sensorthings-0.1.0.tar.gz
Algorithm Hash digest
SHA256 21cb2abb7f62e07dd97071842ae9f27b03faed62799989085e262ba78c8090e0
MD5 90a9e68f6b630062f174a1454c9f5903
BLAKE2b-256 98409f1b8af2b86a4699f7e8adb2362d67a8578c7aefa7939dbc24ae7bed1e4e

See more details on using hashes here.

File details

Details for the file atproto_sensorthings-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: atproto_sensorthings-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for atproto_sensorthings-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ae9dfcefb799992e86b27c9592f6feeb84f5f046f939c4b0b2f53bd7aa80db6
MD5 b1d53afd0a9a71f12b4a34d48365a114
BLAKE2b-256 c1b0feddf6efab0e50f4983932d0059d1dc0d71f9504b068c45ddaecefaec3f8

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