Skip to main content

msgspec-geojson

A collection of GeoJSON types for msgspec.

Inspired by the msgspec GeoJSON example code and geojson-pydantic.

This lets you parse GeoJSON into type-safe objects, including properties, and serialize those objects back to GeoJSON:

>>> import msgspec.json
>>> from msgspec import Struct
>>> from msgspec_geojson import Feature, Point

>>> class PoiProperties(Struct):
...    name: str
...    kind: str

>>> obj = msgspec.json.decode("""
...     {"type": "Feature", "id": 1,
...      "properties": {"name": "Zoo Zürich", "kind": "tourism/zoo"},
...      "geometry": {"type": "Point", "coordinates": [8.574695, 47.384510]}}
... """, type=Feature[Point, PoiProperties])

>>> obj.id
1
>>> obj.geometry
Point(coordinates=(8.574695, 47.38451))
>>> obj.properties
PoiProperties(name='Zoo Zürich', kind='tourism/zoo')

>>> feature = Feature(
...     Point(coordinates=(7.5823576, 47.5489249)),
...     PoiProperties(name="Zoo Basel", kind="tourism/zoo"),
... )
>>> msgspec.json.encode(feature)
b'{"type":"Feature","geometry":{"type":"Point","coordinates":[7.5823576,47.5489249]},"properties":{"name":"Zoo Basel","kind":"tourism/zoo"}}'

Download files

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

Source Distribution

msgspec_geojson-0.2.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

msgspec_geojson-0.2.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file msgspec_geojson-0.2.1.tar.gz.

File metadata

  • Download URL: msgspec_geojson-0.2.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for msgspec_geojson-0.2.1.tar.gz
Algorithm Hash digest
SHA256 bc312e87351d7e08e1c58ab8e1a1e4fa5466ab9097f8f40eac7a6bfe9bce88c2
MD5 121645bc1edc93e423b275c26f6d532a
BLAKE2b-256 d4b64d328451255944c106756e0ff28b47e895bf37f6baa8c31f224b59bcecf6

See more details on using hashes here.

File details

Details for the file msgspec_geojson-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: msgspec_geojson-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for msgspec_geojson-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 15bd8100462b5a2a0b1753bff5c3593ef847ab5535fab6afdd377d7bf8f7e7e8
MD5 f486ece75dcf10b9fb00c5c591786360
BLAKE2b-256 d0a556cbdd849dca6e9f8cb9ee090dd96ad6c7030da5c55e5af751ab08022f64

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.2

2 files

This release

0.2.1 This release

2 files

0.2.0

2 files

0.1.0

2 files

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